-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: session.flush() in interceptor postFlush hangs
PostPosted: Wed May 03, 2006 1:54 am 
Newbie

Joined: Thu Sep 15, 2005 6:53 am
Posts: 7
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().


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 4:06 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
on postFlush the session should still be open, so have you tried

session = sessionFactory.getCurrentSession();

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject: session.flush() in interceptor postFlush hangs
PostPosted: Thu May 04, 2006 7:21 am 
Newbie

Joined: Thu Sep 15, 2005 6:53 am
Posts: 7
I was able to resolve after following changes:
1 from the hibernate mapping files, i took out the auto commit and auto close properties.
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
2 in the process bean, call made to flush and close session.
No change in the code inside postFlush method.

So i am not sure if this is issue with Hibernate or Sun AppServer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.