Hi,
Env : Hibernate 3.0.5, Sun Application Server 8.0
Condition :
During PostFlush method of Audit Interceptor, insert into audit table hangs. This is happening when the same use case is executed twice.... It works well first time. Entries go in the audit tables and business entities tables also get updated. But on second hit in postFlush method, when it fires insert query on entities table, it just hangs there. Hibernate mapping file has auto flush property and session close set to true.
Code:
Interceptor code for postFlush:
try{
session = sessionFactory.openSession(getConnection());
auditInformation.setEntitiesAudited(auditedEntities);
session.saveOrUpdate(auditInformation);
}catch(HibernateException he){
logger.severe("postFlush hibernate exception occurred "+he);
throw new RuntimeException(he);
}finally{
inserts.clear();
updates.clear();
deletes.clear();
changedIds.clear();
session.flush(); // It hangs after this statement.
session.close();
}
Business Code:
Session auditSession=auditSessionFactory.getCurrentSession();
AuditInformation auditInformation= AuditManager.createAuditEntry(EventType.UPDATE_CLAIM_CODES.toString(),userId,0l,null,auditSession);
HibernateAuditInterceptor hibernateAuditInterceptor=new HibernateAuditInterceptor(auditInformation, auditSessionFactory, auditSession.connection());
Session session = HibernateUtil.getSession("HibernateSessionFactory", hibernateAuditInterceptor);
UpliftMain um = new UpliftMain();
um.updateClaimCode(vehiclesWithInvalidClaimCodeDTOList,session);
I am not able to find out when its working fine first time, why its failing second time . It looks like some lock is held on the audit table. It hangs after session.flsuh().
|