Hi,
we are using Hibernate 2.1.2 with JBoss 3.2.1. The project uses EntityBeans as persistence layer. For some new functions we want to use Hibernate.
How we use it: The client (other SessionBean, Servlet, JUnitEJB Test) calls a method on a stateless facade-SessionBean. This facade works with stateful SessionBeans (Session for EntityBeans) and/or with hibernate objects and may also call other facades. The hibernate objects don't only have getters and setters, they also have some methods that perform some logic (for example dont get all associated objects but the objects that have a special attribute).
We use the ThreadLocal pattern and the HibernateSession. If I use the Hibernate objects directly it works perfect. I open the Session with HibernateSession.openSession(), do some work and call HibernateSession.closeSession().
But if we are using the facade Session Beans we have the same problem like in this thread
http://forum.hibernate.org/viewtopic.php?t=77.
20:25:12,263 INFO [TxConnectionManager$TxConnectionEventListener] throwable from unregister connection
java.lang.IllegalStateException: Trying to return an unknown connection1! org.jboss.resource.adapter.jdbc.WrappedConnection@2b7632
at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:264)
We placed the Hibernate.openSession() and Hibernate.closeSession() calls in all Methods of the facade Bean. Do I have to open a Session in every method that works with hibernate objects (that only calls a getter)? Or is the facade the wrong place to open the Session? Should the client do this?