Hi,
In our project we are using a mix of both CMT and BMT stateless session beans. Previously we were using entity beans for persisting the data and now I've removed all the entity beans from the system.
For intergrating the hibernate with the app server(JBoss) I'm using the "HibernateSession" class provided by steve (
http://forum.hibernate.org/viewtopic.php?p=504). It is working perfectly for all the Container Managed Transaction beans.
However, for the BMT beans, when I use the "HibernateSession", during closing the session an error is thrown saying
Code:
java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection
at org.jboss.resource.adapter.jdbc.local.LocalConnection.checkStatus(LocalConnection.java:774)
at org.jboss.resource.adapter.jdbc.local.LocalConnection.getWarnings(LocalConnection.java:573)
at net.sf.hibernate.impl.SessionFactoryImpl.closeConnection(SessionFactoryImpl.java:321)
at net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:3159)
at net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:471)
...
Here's the piece of the code that manages the transactions in EJB for BMT case.
Code:
try
{
UserTransaction ut = sessionCtx.getUserTransaction();
ut.begin();
Session session = HibernateSession.currentSession();
//...Use the session here to perform the operations
ut.commit();
}
catch(Exception e)
{
ut.rollback();
}
finally
{
HibernateSession.closeSession();
}
I have also tried to change the above code something like
Code:
Transaction tx = HibernateSession.currentSession.beginTransaction();
//....Actual code
tx.commit();
In that case also I'm getting the same exception.
The transaction attribute for the methods are in the "Supports" level. (I have also changed this to "Required" level, but no use).
Can anybody please explain me how to use hibernate with BMT session beans?
I'm using JBoss 3.0.3 and Hibernate 2.1 r2.
Regards,
Balakrishnan.