Hibernate Team |
|
Joined: Tue Aug 26, 2003 3:00 pm Posts: 1816 Location: Austin, TX
|
Well the simpliest way to "reuse" the SessionFactory in J2EE containers is to either 1) bind the SessionFactory into JNDI (see the xml config docs for info on how to do this); or 2) utilize a singleton helper class which manages the SessionFactory reference.
If you do not like the ThreadLocalPattern, then you need to come up with a way for the helper classes of your EJBs to have access to the session bound to the current call. But first, you'd have to determine how the session is to get bound to the context of the current call. Something like the Springframework or PicoContainer can help here. I've used Hibernate and Spring together in conjunction with EJBs and it worked really well. The best part was the ability to take the code outside of the J2EE container and run it (for, say, testing purposes).
|
|