Dharmendra, Thanks for your reply.
I'm trying to start the tx in the constructor of my DAO but it throws the same error (actually doesn't matter where I put it , same error). I must be starting the tx incorrectly. Do I have to start the tx using a different method? here is the DAO constructor .. which throws the error.
Code:
public class UiPlanTypeDAO {
public UiPlanTypeDAO() {
HibernateUtilMitigation.getSessionFactory().getCurrentSession().beginTransaction();
based on this example:
http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/09/Code:
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
s.beginTransaction();
s.save(item);
// or
HibernateUtil.getSessionFactory().getCurrentSession().save(item);
s.getTransaction().commit();
I see from the jboss/hibernate wiki page the tx must exist first but I don't see how that reconciles with the above example ..
Quote:
Since version 3.0.1, Hibernate itself has the ability to track the "current session" and to expose that to applications through the getCurrentSession() method of the SessionFactory.
If the given ~SessionFactory has already bound a session to the "current context", then sucessive calls to getCurrentSession() will continue to return the same session;
if not, a new Session is generated, bound to the "current context", and then returned.
One caveat to note here is that due to the use of the Transaction to
scope or track the current session, the JTA transaction must be started
prior to the session initially being bound.
THanks