Hibernate version: Hibernate 2.1.2
Name and version of the database you are using:MySql
I have a class 'Gebaeude' and a Subclass 'Lagerhaus'.
I have decided to use the table per Subclass strategy to reflect inheritence.
If I create a Lagerhaus la = new Lagerhaus() and execute session.save(la) I encounter a problem:
The 1st table that holds the Information of the Gebauede.class is treated correctly. A new line is inserted, an ID is generated automatically.
But the table of the joined subclass that holds the info of Lagerhaus.class is not touched. It should be inserted here an extra line with a reference to the new line in the Gebaeude-Table. but it is not. An 'net.sf.hibernate.AssertionFailure: null id in entry ' occures.
If I execute session.save(la,"123") the problem does not appear. both tables are filled correctly with use of the id 123.
What can I do to use the hibernate feature of generated Ids with joined sublasses?
It seems that the information of the generated id is not available to the insert in the table of the sublass.
Thanks!
Kai
here is the relevant mapping (further down you find the relevant log-entries):
<hibernate-mapping>
<class name="beans.Gebaeude" table="GEBAEUDE">
<id name="id" type="string" unsaved-value="null" >
<column name="GEBAEUDE_ID" sql-type="int UNSIGNED"/>
<generator class="identity"/>
</id>
<property name="typ" type="string" >
<column name="TYP" sql-type="varchar(16)" not-null="true"/>
</property>
[...]
<joined-subclass name="beans.Lagerhaus" table="LAGERHAUS">
<key column="GEBAEUDE_ID"/>
<property name="text" type="string">
<column name="TEXT" sql-type="varchar(25)"/>
</property>
</joined-subclass>
</class>
</hibernate-mapping>
Logfile:
16:43:46,773 [DEBUG] [ibernate.impl.SessionImpl] : 531 - opened session
16:43:46,777 [DEBUG] [ansaction.JDBCTransaction] : 37 - begin
16:43:46,779 [DEBUG] [ManagerConnectionProvider] : 78 - total checked-out connections: 0
16:43:46,780 [DEBUG] [ManagerConnectionProvider] : 84 - using pooled JDBC connection, pool size: 0
16:43:46,782 [DEBUG] [ansaction.JDBCTransaction] : 41 - current autocommit status:false
16:43:46,795 [DEBUG] [gruppe.jsp ] : 70 - baue Lagerhaus
16:43:46,801 [DEBUG] [ibernate.impl.SessionImpl] : 807 - saving [beans.Lagerhaus#<null>]
16:43:46,802 [DEBUG] [ibernate.impl.SessionImpl] : 2273 - executing insertions
16:43:46,803 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,804 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,804 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,805 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,809 [DEBUG] [NormalizedEntityPersister] : 486 - Inserting entity: beans.Lagerhaus (native id)
16:43:46,810 [DEBUG] [ibernate.impl.BatcherImpl] : 196 - about to open: 0 open PreparedStatements, 0 open ResultSets
16:43:46,811 [DEBUG] [net.sf.hibernate.SQL ] : 237 - insert into GEBAEUDE (TYP, STATUS, STUFE, EFFIZIENZ, LAGERRAUM, PERSON_ID, HIMMELSKOERPER_ID, SIEDLUNG_ID, ZONE, GEBIET_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:43:46,816 [DEBUG] [ibernate.impl.BatcherImpl] : 241 - preparing statement
16:43:46,823 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,824 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,825 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,826 [DEBUG] [hibernate.engine.Cascades] : 341 - id unsaved-value strategy NULL
16:43:46,843 [DEBUG] [ibernate.impl.BatcherImpl] : 203 - done closing: 0 open PreparedStatements, 0 open ResultSets
16:43:46,845 [DEBUG] [ibernate.impl.BatcherImpl] : 261 - closing statement
16:43:46,858 [DEBUG] [ansaction.JDBCTransaction] : 59 - commit
16:43:46,859 [DEBUG] [ibernate.impl.SessionImpl] : 2210 - flushing session
16:43:46,861 [DEBUG] [ibernate.impl.SessionImpl] : 2403 - Flushing entities and processing referenced collections
16:43:46,866 [ERROR] [ibernate.AssertionFailure] : 22 - 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: null id in entry (don't flush the Session after an exception occurs)
at net.sf.hibernate.impl.SessionImpl.checkId(SessionImpl.java:2605)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2429)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2422)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2224)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2203)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at db.hibernate.util.SessionManager.closeSession(SessionManager.java:73)
at db.hibernate.util.SessionManager.doFilter(SessionManager.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)
16:50:42,071 [ INFO] [e.impl.SessionFactoryImpl] : 531 - closing
|