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]