Hello, 

In Hibernate3 I think that you should use SessionFactory.getCurrentSession() 
instead of HibernateContext. I think that will do the same thing in application 
server independent way.

But the problem that I see here is that neither of these will work if you are 
not inside a transaction. And I would like to keep the code similar whether I'm 
inside transaction or not. And it feels unnecessary overhead to have 
transaction in every select method.

One solution that came to my mind is that create a HibernateUtil that uses 
SessionFactory.getCurrentSession(), traps exception that happens if transaction 
is not running, and then creates and returns ThreadLocal session instead. 

The closeSession() method would have to close the session if it is ThreadLocal 
session and do nothing if it's Transaction related session. Don't know would 
this work, but I'm going to try...

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878713#3878713

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878713


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to