indianmanju wrote:
It would be of a great help for me, if you can send me the properties to
be configured in hibernate.properties.
I am trying to use Weblogic App server with a Stateless/Stateful session
bean having the Hibernate access. i.e. I need to open a session and
execute the queries on the persistent objects in the Session EJB.
Pardon, but I have not used hibernate with Weblogic and know nothing about configuring hibernate to work with Weblogic.
Quote:
Also, if possible pls explain me as to how transaction works in this scenario. Can i use container managed transactions? If so, how do i do it?
If you use properly configured hibernate inside CMT environment, container manages all hibernate transactions, so you don't need to call tx = sess.beginTransaction() and tx.commit(), but if you call, it does not start and does not commit transaction (container does it for you), and don't forget to call sessionContext.setRollbackOnly() on all application level exceptions.
http://forum.hibernate.org/viewtopic.php?p=2193148#2193148
Here michael desribes me and other guys how to work with hibernate inside CMT.
I use the following approach for all Session Beans:
Code:
try
{
session = HibernateUtil.currentSession();
//...
session.flus();
}
catch (HibernateException e)
{
sessionContext.setRollbackOnly();
log.error("...", e);
throw new ApplicationLevelException(...);
}
catch (ApplicationLevelException e)
{
sessionContext.setRollbackOnly();
log.error("...", e);
throw e;
}
finally
{
HibernateUtil.closeSession();
}
To get hibernate session use HibernateUtil from CaveatEmptor example
http://caveatemptor.hibernate.org/5.html
--
Leonid