-->
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.  [ 1 post ] 
Author Message
 Post subject: possible nonthreadsafe access to session
PostPosted: Mon May 11, 2009 6:07 am 
Newbie

Joined: Mon Oct 31, 2005 12:01 pm
Posts: 12
I found a strange behavior in Hibernate, that I can't explain.

I have a folowing scenarion
Code:
session.update(parent);

//add new child to the parent object
Child c = new Child()
....
parent.addChild(c);
...
session.clear(); // session is cleared or closed and another session opened
session.update(parent);
session.evict(parent); // at this moment the session should be empty?
session.flush(); // throws an exception. why ??????
   => org.hibernate.AssertionFailure: possible nonthreadsafe access to session

It seems like as the child objects are not evicted properly or something like that,
but if I debug, I can see that
session.getStatistics().getCollectionCount() == 0
and
session.getStatistics().getEntityCount() == 0
before flush.

And this code works

Code:
session.update(parent);

//add new child to the parent object
Child c = new Child()
....
parent.addChild(c);
...
session.clear(); // session is cleared or closed and another session opened
session.update(parent);
//close or clear session and update one more time
session.clear(); // session is cleared or closed and another session opened
session.update(parent);

session.evict(parent); // at this moment the session should be empty?
session.flush(); // no exception is thrown. why??????
   

Can somebody explain this behavior?


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

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.