From: Andrew F. (JIRA) <no...@at...> - 2005-09-27 10:46:38
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-779?page=comments#action_19936 ] Andrew Fung commented on HHH-779: --------------------------------- I had a similar problem with the use of Session.evict() and subsequently trying to reassociate within the same session (i.e. before Session.close) using Session.save() (or update). For the most part, it seemed to resolve if I called Session.flush() after the Session.evict(). I still had problems trying to use the evicted instance to Session.load() an object for deletion though. I ended up tossing the whole idea out and going with the optimistic concurrency collision detection that Hibernate supports (i.e. versions/timestamps). > Assertion failure occured with Hibernate 3 saving objects > --------------------------------------------------------- > > Key: HHH-779 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-779 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.0.5 > Environment: Hibernate 3.0.5, SQL Server 2000 SP2 > Reporter: Alessandro Rizzi > Fix For: 3.1 beta 2 > > > I have this exception: > SEVERE: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) > org.hibernate.AssertionFailure: null identifier > at org.hibernate.engine.EntityKey.<init>(EntityKey.java:33) > at org.hibernate.event.def.DefaultEvictEventListener.onEvict(DefaultEvictEventListener.java:51) > at org.hibernate.impl.SessionImpl.evict(SessionImpl.java:702) > at testHib3.starter.go(starter.java:69) > at testHib3.starter.main(starter.java:22) > org.hibernate.AssertionFailure: null identifier > at org.hibernate.engine.EntityKey.<init>(EntityKey.java:33) > at org.hibernate.event.def.DefaultEvictEventListener.onEvict(DefaultEvictEventListener.java:51) > at org.hibernate.impl.SessionImpl.evict(SessionImpl.java:702) > at testHib3.starter.go(starter.java:69) > at testHib3.starter.main(starter.java:22) > with this code: > Session hibSession = sf.openSession(); > tstDACmain m = (tstDACmain)hibSession.load( tstDACmain.class, new Long(1) ); > m.setId( null ); > hibSession.evict( m); > hibSession.saveOrUpdate( m ); > hibSession.flush(); > and this mapping document: > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 1.1//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> > <hibernate-mapping> > <class name="testHib3.tstDACmain" table="tst_main"> > <id column="id" name="id" type="long"> > <generator class="native"></generator> > </id> > <property column="des" length="50" name="des" not-null="false" type="string"/> > </class> > </hibernate-mapping> > Notice that if you change the code like this: > From: > tstDACmain m = (tstDACmain)hibSession.load( tstDACmain.class, new Long(1) ); > To: > tstDACmain m = new tstDACmain(); > hibSession.load( m, new Long(1) ); > then it works perfectly. No error occurs, and the object is saved in the database. > I did not have this error on Hibernate 2.1.8. > Regards > Alessandro Rizzi -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |