I am using hibernate 3.0, with EJB 3.0 and JPA 1.0 in JBOSS 6 and Database Postgres 8.4.8.
I have used JTATransactionFactory for managing the transaction automatically.
Session is used by SessionFactory.getCurrentSession() method.
Autocommit is 'true' in hibernate.cfg.xml.
I am using the following code for rollbacking the txn.
@SessionContext ctx;
some business method { ///done some task
//update the database by ''Factory.getCurrentSession().persist(..);"
ctx.setRollBackOnly(); //working correctly
}
If i rollback here, this does the way it should do.
But if i again fetch the data of the same entityBean again by using namedQuery, it flushes the data, and I think also auto committing the data to DB, which is not allowing it to be rollbacked.
Code will look like this,
some business method { ///done some task
//update the database by ''Factory.getCurrentSession().persist(x);"
List<x> list = SessionFactory.getCurrentSession().getNameQuery(..).list();
ctx.setRollBackOnly(); //not workking here
}
Please reply me as i was not facing the problem when i was using EntityManager to fetch the Data from persistenceContext. Is this is the problem in this hibernate version, or any other setting that i am missing.
|