-->
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: AssertionFailure: possible nonthreadsafe access to session?
PostPosted: Thu Apr 29, 2004 9:56 am 
Newbie

Joined: Mon Mar 22, 2004 8:42 am
Posts: 2
I'm getting an AssertionException in my app:
-----
net.sf.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
net.sf.hibernate.AssertionFailure: possible nonthreadsafe access to session
-----

What I'm trying to do is move an earlier inserted to another database, both of which are accessed via Hibernate.

What I'm doing amounts to this:

Code:
Session ses1 = (working session for DB1);
Session ses2 = (working session for DB2);
Transaction trans1 = ses1.beginTransaction();
Transaction trans2 = ses2.beginTransaction();

ses1.save(object1);

trans1.commit();
trans1 = ses1.beginTransaction();

Collection listing = ses1().query("statement");
// Listing includes object1 which we just saved and committed.
Iterator it = listing.iterator();
while (it.hasNext()) {
    object1 = (type)it.next();
    object1.setMigrated(true);
    ses2.save(object1);
    ses1.delete(object1);
}
ses2.commit();
ses1.commit();


So I create an object, store it and commit the transaction which I stored it. Using the same session I create another transaction, reload that same object from DB1, alter it, store it in DB2 and remove it from DB1, then commit both sessions.

Everything's cool until I reach that second commit at which time I get:
Code:
2004-04-29 15:22:55,178 [main] ERROR net.sf.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
net.sf.hibernate.AssertionFailure: possible nonthreadsafe access to session
        at net.sf.hibernate.impl.SessionImpl.postDelete(SessionImpl.java:2381)
        at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:30)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2365)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
        at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


When I first ran into this problem I was running Hibernate 2.0.3 which didn't complain about anything, but simply failed to remove a part of the previously stored object from its table (a part which was present in the object when it was first committed), resulting in an SQLException later on when I tried to remove a object it was related to (foreign key constraint violated).

I've migrated the app to Hibernate 2.1.3 now and have since gotten the AssertionFailure.

If anybody has any ideas as to what it is I might be doing wrong here, I'm all ears.

Kind regards,

Cooper
--
I don't need a pass to pass this pass!
- Groo The Wanderer -[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 30, 2004 1:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You'll probably need to evict the object before saving it.

_________________
Emmanuel


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.