-->
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.  [ 2 posts ] 
Author Message
 Post subject: ActionQueue not cleared properly
PostPosted: Wed Apr 04, 2007 9:28 am 
Newbie

Joined: Tue Aug 09, 2005 4:01 am
Posts: 7
Hibernate version:
Hibernate-Version: 3.1.3

Hi,
I have encountered a problem with the class org.hibernate.engine.ActionQueue and I don't see a good resolution.

When I try to delete an entity from the database and a constraint error occurs I do a transaction rollback. In my case after such an error has happened I have to begin a new transaction and perform a list(). The problem is that when making the list() Hibernate comes up with an AssertionFailure("possible nonthreadsafe access to session"). This failure comes from
org.hibernate.action.EntityDeleteAction.execute():83

From what I understood the entity was removed from the persistence context when the delete was called and when the execute() is called again the entry is not found:

Code:
EntityEntry entry = persistenceContext.removeEntry( instance );
if ( entry == null ) {
   throw new AssertionFailure( "possible nonthreadsafe access to session" );
}


I was wondering why the delete action is called for the list() and found out that the deletions list that contains SQLs to execute is left behind after the call to delete.

In
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions()
we have the following line:
session.getActionQueue().executeActions();

This calls org.hibernate.engine.ActionQueue.executeActions() that contains
executeActions(deletions):
Code:
private void executeActions(List list) throws HibernateException {
   int size = list.size();
   for ( int i = 0; i < size; i++ ) {
      execute( (Executable) list.get(i) );
   }
   list.clear();
   session.getBatcher().executeBatch();
}


From what I see here when my delete sql is rejected due to a constraint violation the deletions list is not cleared. When I scanned through the usages I didn't find other occurrences of clear(). I guess that there is some problem with the execution flow and maybe the clear() should also be made at some other point.

Why is the deletions collection not cleared when I have begun a new transaction?

Do I have to call a clear by hand after an unsuccessful delete?
Something like:
Code:
((EventSource)HibernateUtils.currentSession()).getActionQueue().clear();

or
Code:
HibernateUtils.currentSession().clear();

_________________
Regards,
Alexander Kamburov

wise_guybg at yahoo.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 9:33 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Anytime a transaction is rolled back, the Hibernate session is left in an inconsistent state. Make sure you close the session and start a new one before proceeding.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.