Hi there, have a somewhat strange problem. I have two classes, mapped as below. On the Mode Of Transport, the insert string does not contain the discriminator property, on the Package Type it does. Any ideas why?
btw, I've tried to pair down the logs and sql, as they run to about 20Mb for a single deployment in this application when hibernate is on debug.
Hibernate version: 3.0.3
Mapping documents:
Code:
<hibernate-mapping auto-import="false">
<class
name="com.dcs.common.entities.ModeOfTransport"
table="cmn_MODE_OF_TRANSPORT"
>
<id
name="id"
column="ID"
type="java.lang.String"
length="32"
>
<generator class="uuid.hex">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ModeOfTransport.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<discriminator
column="CLASS"
/>
<property
name="code"
type="java.lang.String"
update="true"
insert="true"
column="dcs_CODE"
/>
<set
name="localeDatas"
lazy="true"
cascade="all"
sort="unsorted"
>
<key
column="dcs_MODE_OF_TRANSPORT_FK_LOCAL"
>
</key>
<one-to-many
class="com.dcs.common.entities.LocaleData"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ModeOfTransport.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code:
<hibernate-mapping
auto-import="false"
>
<class
name="com.dcs.common.entities.PackageType"
table="cmn_PACKAGE_TYPE"
>
<id
name="id"
column="ID"
type="java.lang.String"
length="32"
>
<generator class="uuid.hex">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-PackageType.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<discriminator
column="CLASS"
/>
<property
name="code"
type="java.lang.String"
update="true"
insert="true"
column="dcs_CODE"
/>
<set
name="localeDatas"
lazy="true"
cascade="all"
sort="unsorted"
>
<key
column="dcs_PACKAGE_TYPE_FK_LOCALE_DAT"
>
</key>
<one-to-many
class="com.dcs.common.entities.LocaleData"
/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-PackageType.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():(In CMT with the auto close and auto flush thingys turned on)
Session session = HibernateUtils.getSessionFactory().getCurrentSession();
ModeOfTransport mot = new ModeOfTransport();
mot.setCode("AIR");
session.saveOrUpdate(mot);
Full stack trace of any exception that occurs:Code:
2005-07-12 14:31:03,654 [server.startup : 8] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
2005-07-12 14:31:03,654 [server.startup : 8] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Inserting entity: [com.dcs.common.entities.ModeOfTran
sport#ff808081050b3d3401050b3dcb3a011c]
2005-07-12 14:31:03,655 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally:
0)
2005-07-12 14:31:03,655 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection
2005-07-12 14:31:03,655 [server.startup : 8] DEBUG org.hibernate.SQL - insert into cmn_MODE_OF_TRANSPORT (dcs_CODE, ID) values (?, ?)
2005-07-12 14:31:03,655 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-07-12 14:31:03,655 [server.startup : 8] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [com.dcs.common.entities.ModeOfTr
ansport#ff808081050b3d3401050b3dcb3a011c]
2005-07-12 14:31:03,656 [server.startup : 8] DEBUG org.hibernate.type.StringType - binding 'AIR' to parameter: 1
2005-07-12 14:31:03,656 [server.startup : 8] DEBUG org.hibernate.type.StringType - binding 'ff808081050b3d3401050b3dcb3a011c' to parameter: 2
2005-07-12 14:31:03,699 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally
: 1)
2005-07-12 14:31:03,700 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
2005-07-12 14:31:03,700 [server.startup : 8] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (ope
n ResultSets: 0, globally: 0)
2005-07-12 14:31:03,713 [server.startup : 8] DEBUG org.hibernate.util.JDBCExceptionReporter - could not insert: [com.dcs.common.entities.ModeOfTransport] [ins
ert into cmn_MODE_OF_TRANSPORT (dcs_CODE, ID) values (?, ?)]
com.ibm.db2.jcc.b.SqlException: Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=63, COLNO=1" is not allowed.
at com.ibm.db2.jcc.b.id.d(id.java:1385)
at com.ibm.db2.jcc.c.fb.l(fb.java:366)
at com.ibm.db2.jcc.c.fb.a(fb.java:64)
at com.ibm.db2.jcc.c.s.a(s.java:48)
at com.ibm.db2.jcc.c.xb.c(xb.java:266)
at com.ibm.db2.jcc.b.jd.ab(jd.java:1684)
at com.ibm.db2.jcc.b.jd.a(jd.java:2253)
at com.ibm.db2.jcc.b.jd.W(jd.java:537)
at com.ibm.db2.jcc.b.jd.executeUpdate(jd.java:520)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:701)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:527)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1843)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2190)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
at com.dcs.common.service.LogicModuleServiceBean.generateDataFromCSV(LogicModuleServiceBean.java:342)
Name and version of the database you are using:DB2 UDB 8.1 Fixpak 9
The generated SQL (show_sql=true):SQL from schema exporter:
Code:
DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create table cmn_MODE_OF_TRANSPORT (ID varchar(32) not null, CLASS varchar(255) not null, dcs_CODE varchar(255), primary key (ID))
SQL being executed:
Code:
insert into cmn_MODE_OF_TRANSPORT (dcs_CODE, ID) values (?, ?)
Debug level Hibernate log excerpt:This is the debug from the BasicEntityPersister:
Code:
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Static SQL for entity: com.dcs.common.entities.ModeOfTransport
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Version select: select ID from cmn_MODE_OF_TRANSPORT where ID =?
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Snapshot select: select modeoftran_.ID, modeoftran_.dcs_CODE as dcs3_117_
from cmn_MODE_OF_TRANSPORT modeoftran_ where modeoftran_.ID=?
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Insert 0: insert into cmn_MODE_OF_TRANSPORT (dcs_CODE, ID) values (?, ?)
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Update 0: update cmn_MODE_OF_TRANSPORT set dcs_CODE=? where ID=?
2005-07-12 15:37:12,340 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Delete 0: delete from cmn_MODE_OF_TRANSPORT where ID=?
Code:
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Static SQL for entity: com.dcs.common.entities.PackageType
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Version select: select ID from cmn_PACKAGE_TYPE where ID =?
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Snapshot select: select packagetyp_.ID, packagetyp_.dcs_CODE as dcs3_112_
from cmn_PACKAGE_TYPE packagetyp_ where packagetyp_.ID=?
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Insert 0: insert into cmn_PACKAGE_TYPE (dcs_CODE, CLASS, ID) values (?, '
com.dcs.common.entities.PackageType', ?)
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Update 0: update cmn_PACKAGE_TYPE set dcs_CODE=? where ID=?
2005-07-12 15:37:08,729 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Delete 0: delete from cmn_PACKAGE_TYPE where ID=?