Hi all,
I am facing a problem with cache locking.
The code is as follows:
Inside "onUpdate" (Lifecycle) method, I open one more session and save different object to database. Then I close this new session and refresh current session. These two sessions are part of same transaction.
public boolean onUpdate(Session session) throws CallbackException {
SessionFactory sessionFactory = ServiceLocator
.getInstance().getHibernateSessionFactory();
Session newSession = sessionFactory.openSession(session
.connection());
newSession.saveOrUpdate(getEmbeddedObject());
newSession.flush();
newSession.close();
session.refresh(this);
return NO_VETO;
}
This new session is closed and current session proceeds with updating "this" entity. But if any error occurs while saving "this" entity, then the lock on cache node is not released.
Is this because of "newSession"?
and Is it safe to have two sessions in a single transaction??
Other specifications are:
Server used: Jboss 3.2.3
Hibernate Cache: TreeCache - transactional
Hibernate Version: 2.0
TransactionStrategy: net.sf.hibernate.transaction.JTATransactionFactory
Entries in Tree-cache.xml
IsolationLevel: REPEATABLE_READ
CacheMode: LOCAL
If anyone can point me to the resource locking in hibernate, that would be helpful.
Regards,
Reshma
|