My problem is the exception below.
Hibernate version:
3.0.5
Mapping documents:
<?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>
Code between sessionFactory.openSession() and session.close():
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();
Full stack trace of any exception that occurs:
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)
Name and version of the database you are using:
SQL Server 2000 SP2
The generated SQL (show_sql=true):
Hibernate: select tstdacmain0_.id as id0_, tstdacmain0_.des as des0_0_ from tst_main tstdacmain0_ where tstdacmain0_.id=?
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.
Should I put into JIRA?
Regards
Alessandro Rizzi
|