From: <leg...@at...> - 2003-09-25 17:06:58
|
The following comment has been added to this issue: Author: Brian Bonner Created: Thu, 25 Sep 2003 12:06 PM Body: Forgot to include the log output: Buildfile: D:\data\eclipseworkspace\TEST\build.xml runtestcase: [java] CA 0 main INFO net.sf.hibernate.cfg.Env= ironment - Hibernate 2.0.3 [java] CA 20 main INFO net.sf.hibernate.cfg.Env= ironment - loaded properties from resource hibernate.properties: {hibernat= e.connection.username=3Duser, hibernate.connection.password=3Ddemo, hiberna= te.cglib.use_reflection_optimizer=3Dtrue, hibernate.dialect=3Dnet.sf.hibern= ate.dialect.DB2Dialect, hibernate.connection.url=3Djdbc:db2:pbbtest, hibern= ate.connection.driver_class=3DCOM.ibm.db2.jdbc.app.DB2Driver} [java] CA 20 main INFO net.sf.hibernate.cfg.Env= ironment - using CGLIB reflection optimizer [java] CA 40 main INFO net.sf.hibernate.cfg.Env= ironment - JVM proxy support: true [java] CA 50 main INFO net.sf.hibernate.cfg.Con= figuration - Mapping resource: com/paraware/domain/Parent.hbm.xml [java] CA 100 main DEBUG net.sf.hibernate.util.DT= DEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern= ate-mapping-2.0.dtd in classpath under net/sf/hibernate/ [java] CA 100 main DEBUG net.sf.hibernate.util.DT= DEntityResolver - found http://hibernate.sourceforge.net/hibernate-mapping= -2.0.dtd in classpath [java] CA 241 main INFO net.sf.hibernate.cfg.Bin= der - Mapping class: com.paraware.domain.Parent -> parents [java] CA 331 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: keyId -> key_id, type: integer [java] CA 351 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: userID -> LogonID, type: string [java] CA 351 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: userName -> Name, type: string [java] CA 361 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: password -> password, type: string [java] CA 361 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: emailAddress -> emailAddress, type: string [java] CA 361 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: lastLogon -> lastLogon, type: timestamp [java] CA 391 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: children, type: java.util.Set [java] CA 391 main INFO net.sf.hibernate.cfg.Con= figuration - Mapping resource: com/paraware/domain/Child.hbm.xml [java] CA 391 main DEBUG net.sf.hibernate.util.DT= DEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern= ate-mapping-2.0.dtd in classpath under net/sf/hibernate/ [java] CA 391 main DEBUG net.sf.hibernate.util.DT= DEntityResolver - found http://hibernate.sourceforge.net/hibernate-mapping= -2.0.dtd in classpath [java] CA 431 main INFO net.sf.hibernate.cfg.Bin= der - Mapping class: com.paraware.domain.Child -> children [java] CA 431 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: mouseId -> mouse_id, type: integer [java] CA 431 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: name -> name, type: string [java] CA 441 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped property: parent -> key_id, type: com.paraware.domain.Parent [java] CA 441 main INFO net.sf.hibernate.cfg.Con= figuration - processing one-to-many association mappings [java] CA 451 main DEBUG net.sf.hibernate.cfg.Bin= der - Second pass for collection: com.paraware.domain.Parent.children [java] CA 451 main INFO net.sf.hibernate.cfg.Bin= der - Mapping collection: com.paraware.domain.Parent.children -> children [java] CA 471 main DEBUG net.sf.hibernate.cfg.Bin= der - Mapped collection key: key_id, one-to-many: com.paraware.domain.Chil= d [java] CA 471 main INFO net.sf.hibernate.cfg.Con= figuration - processing foreign key constraints [java] CA 471 main DEBUG net.sf.hibernate.cfg.Con= figuration - resolving reference to class: com.paraware.domain.Parent [java] CA 841 main INFO net.sf.hibernate.impl.Se= ssionFactoryImpl - building session factory [java] CA 841 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - instantiating session factory with properties: {java.ru= ntime.name=3DJava(TM) 2 Runtime Environment, Standard Edition, hibernate.co= nnection.password=3Ddemo, sun.boot.library.path=3DD:\j2sdk1.4.2\jre\bin, ja= va.vm.version=3D1.4.2-b28, hibernate.connection.username=3Duser, java.vm.ve= ndor=3DSun Microsystems Inc., java.vendor.url=3Dhttp://java.sun.com/, path.= separator=3D;, java.vm.name=3DJava HotSpot(TM) Client VM, file.encoding.pkg= =3Dsun.io, user.country=3DUS, sun.os.patch.level=3DService Pack 4, java.vm.= specification.name=3DJava Virtual Machine Specification, user.dir=3DD:\data= \eclipseworkspace\TEST, java.runtime.version=3D1.4.2-b28, java.awt.graphics= env=3Dsun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=3DD:\j2sdk1.4.2\= jre\lib\endorsed, os.arch=3Dx86, java.io.tmpdir=3DC:\DOCUME~1\BBONNE~1.MIC\= LOCALS~1\Temp\, line.separator=3D [java] , java.vm.specification.vendor=3DSun Microsystems Inc., user= .variant=3D, os.name=3DWindows 2000, sun.java2d.fontpath=3D, java.library.p= ath=3DD:\j2sdk1.4.2\jre\bin;.;C:\WINNT\system32;C:\WINNT;d:\j2sdk1.4.2\bin;= c:\winnt\system32;d:\sqllib\bin;"d:\program files\ibm\mqseries\bin";d:\cygw= in\bin;d:\dev\java\apache-ant-1.5.3-1\bin, java.specification.name=3DJava P= latform API Specification, java.class.version=3D48.0, java.util.prefs.Prefe= rencesFactory=3Djava.util.prefs.WindowsPreferencesFactory, os.version=3D5.0= , user.home=3DC:\Documents and Settings\bbonner.MICKEY, user.timezone=3D, j= ava.awt.printerjob=3Dsun.awt.windows.WPrinterJob, file.encoding=3DCp1252, j= ava.specification.version=3D1.4, hibernate.connection.driver_class=3DCOM.ib= m.db2.jdbc.app.DB2Driver, user.name=3Dbbonner, java.class.path=3DD:\data\ec= lipseworkspace\TEST\bin;D:\data\eclipseworkspace\TEST\lib\c3p0.jar;D:\data\= eclipseworkspace\TEST\lib\cglib.jar;D:\data\eclipseworkspace\TEST\lib\commo= ns-beanutils-1.6.1.jar;D:\data\eclipseworkspace\TEST\lib\commons-collection= s-2.1.jar;D:\data\eclipseworkspace\TEST\lib\commons-dbcp.jar;D:\data\eclips= eworkspace\TEST\lib\commons-lang-1.0.1.jar;D:\data\eclipseworkspace\TEST\li= b\commons-logging-1.0.2.jar;D:\data\eclipseworkspace\TEST\lib\commons-loggi= ng-api-1.0.2.jar;D:\data\eclipseworkspace\TEST\lib\db2java.jar;D:\data\ecli= pseworkspace\TEST\lib\dom4j.jar;D:\data\eclipseworkspace\TEST\lib\hibernate= 2.jar;D:\data\eclipseworkspace\TEST\lib\log4j-1.2.8.jar;D:\data\eclipsework= space\TEST\lib\odmg.jar, java.vm.specification.version=3D1.0, sun.arch.data= .model=3D32, java.home=3DD:\j2sdk1.4.2\jre, hibernate.connection.url=3Djdbc= :db2:pbbtest, hibernate.dialect=3Dnet.sf.hibernate.dialect.DB2Dialect, java= .specification.vendor=3DSun Microsystems Inc., user.language=3Den, awt.tool= kit=3Dsun.awt.windows.WToolkit, java.vm.info=3Dmixed mode, hibernate.cglib.= use_reflection_optimizer=3Dtrue, java.version=3D1.4.2, java.ext.dirs=3DD:\j= 2sdk1.4.2\jre\lib\ext, sun.boot.class.path=3DD:\j2sdk1.4.2\jre\lib\rt.jar;D= :\j2sdk1.4.2\jre\lib\i18n.jar;D:\j2sdk1.4.2\jre\lib\sunrsasign.jar;D:\j2sdk= 1.4.2\jre\lib\jsse.jar;D:\j2sdk1.4.2\jre\lib\jce.jar;D:\j2sdk1.4.2\jre\lib\= charsets.jar;D:\j2sdk1.4.2\jre\classes, java.vendor=3DSun Microsystems Inc.= , file.separator=3D\, java.vendor.url.bug=3Dhttp://java.sun.com/cgi-bin/bug= report.cgi, sun.cpu.endian=3Dlittle, sun.io.unicode.encoding=3DUnicodeLittl= e, sun.cpu.isalist=3Dpentium i486 i386} [java] CA 982 main INFO net.sf.hibernate.dialect= .Dialect - Using dialect: net.sf.hibernate.dialect.DB2Dialect [java] CA 1002 main INFO net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - Hibernate connection pool size: 20 [java] CA 1122 main INFO net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - using driver: COM.ibm.db2.jdbc.app.D= B2Driver at URL: jdbc:db2:pbbtest [java] CA 1122 main INFO net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - connection properties: {user=3Duser,= password=3Ddemo} [java] CA 1122 main INFO net.sf.hibernate.impl.Se= ssionFactoryImpl - Use outer join fetching: true [java] CA 1122 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - total checked-out connections: 0 [java] CA 1162 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - opening new JDBC connection [java] CA 1192 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - created connection to: jdbc:db2:pbbt= est, Isolation Level: 2 [java] CA 1212 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - returning connection to pool, pool s= ize: 1 [java] CA 1212 main INFO net.sf.hibernate.impl.Se= ssionFactoryImpl - Use scrollable result sets: true [java] CA 1673 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryObjectFactory - initializing class SessionFactoryObjectFactory [java] CA 1673 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryObjectFactory - registered: 402881b9f7d9b05400f7d9b059230000 (= unnamed) [java] CA 1673 main INFO net.sf.hibernate.impl.Se= ssionFactoryObjectFactory - no JDNI name configured [java] CA 1673 main INFO net.sf.hibernate.impl.Se= ssionFactoryImpl - Query language substitutions: {} [java] CA 1703 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - instantiated session factory [java] CA 1743 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - opened session [java] CA 1753 main DEBUG net.sf.hibernate.transac= tion.JDBCTransaction - begin [java] CA 1753 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - total checked-out connections: 0 [java] CA 1753 main DEBUG net.sf.hibernate.connect= ion.DriverManagerConnectionProvider - using pooled JDBC connection, pool s= ize: 0 [java] CA 1753 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - saving [com.paraware.domain.Parent#<null>] [java] CA 1783 main DEBUG net.sf.hibernate.engine.= Cascades - processing cascades for: com.paraware.domain.Parent [java] CA 1783 main DEBUG net.sf.hibernate.engine.= Cascades - done processing cascades for: com.paraware.domain.Parent [java] CA 1783 main DEBUG net.sf.hibernate.persist= er.EntityPersister - Inserting entity: com.paraware.domain.Parent (native = id) [java] CA 1783 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets [java] CA 1803 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - prepared statement get: insert into parents (LogonID, N= ame, password, emailAddress, lastLogon, key_id) values (?, ?, ?, ?, ?, defa= ult) [java] CA 1803 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - preparing statement [java] CA 1803 main DEBUG net.sf.hibernate.persist= er.EntityPersister - Dehydrating entity: com.paraware.domain.Parent#null [java] CA 1833 main DEBUG net.sf.hibernate.type.St= ringType - binding 'bnnn' to parameter: 1 [java] CA 1833 main DEBUG net.sf.hibernate.type.St= ringType - binding 'Vivi' to parameter: 2 [java] CA 1833 main DEBUG net.sf.hibernate.type.St= ringType - binding 'abcff' to parameter: 3 [java] CA 1833 main DEBUG net.sf.hibernate.type.St= ringType - binding 'vi...@co...' to parameter: 4 [java] CA 1923 main DEBUG net.sf.hibernate.type.Ti= mestampType - binding '25 September 2003 12:58:55' to parameter: 5 [java] CA 1943 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets [java] CA 1943 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - closing statement [java] CA 1943 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets [java] CA 1943 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - prepared statement get: values IDENTITY_VAL_LOCAL() [java] CA 1963 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - preparing statement [java] CA 1973 main DEBUG net.sf.hibernate.persist= er.EntityPersister - Natively generated identity: 2 [java] CA 1973 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets [java] CA 1973 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - closing statement [java] CA 1993 main DEBUG net.sf.hibernate.engine.= Cascades - processing cascades for: com.paraware.domain.Parent [java] CA 1993 main DEBUG net.sf.hibernate.engine.= Cascades - done processing cascades for: com.paraware.domain.Parent [java] CA 1993 main DEBUG net.sf.hibernate.transac= tion.JDBCTransaction - commit [java] CA 1993 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - flushing session [java] CA 2013 main DEBUG net.sf.hibernate.engine.= Cascades - processing cascades for: com.paraware.domain.Parent [java] CA 2013 main DEBUG net.sf.hibernate.engine.= Cascades - cascading to collection: com.paraware.domain.Parent.children [java] CA 2013 main DEBUG net.sf.hibernate.engine.= Cascades - cascading to saveOrUpdate() [java] CA 2013 main DEBUG net.sf.hibernate.engine.= Cascades - unsaved-value: 0 [java] CA 2033 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - saveOrUpdate() unsaved instance with id: 0 [java] CA 2033 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - saving [com.paraware.domain.Child#<null>] [java] CA 2033 main DEBUG net.sf.hibernate.persist= er.EntityPersister - Inserting entity: com.paraware.domain.Child (native i= d) [java] CA 2033 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets [java] CA 2063 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - prepared statement get: insert into children (name, key= _id, mouse_id) values (?, ?, default) [java] CA 2063 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - preparing statement [java] CA 2063 main DEBUG net.sf.hibernate.persist= er.EntityPersister - Dehydrating entity: com.paraware.domain.Child#null [java] CA 2063 main DEBUG net.sf.hibernate.type.St= ringType - binding 'Mouse' to parameter: 1 [java] CA 2083 main DEBUG net.sf.hibernate.type.In= tegerType - binding '2' to parameter: 2 [java] CA 2093 main DEBUG net.sf.hibernate.util.JD= BCExceptionReporter - SQL Exception [java] COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL= 0803N One or more values in the INSERT statement, UPDATE statement, or for= eign key update caused by a DELETE statement are not valid because the prim= ary key, unique constraint or unique index identified by "1" constrains tab= le "USER.CHILDREN" from having duplicate rows for those columns. SQLSTATE= =3D23505 [java]=20 [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:269) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:206) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_retur= n_code(SQLExceptionGenerator.java:457) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2= PreparedStatement.java:1429) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdat= e(DB2PreparedStatement.java:1021) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:504) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:444) [java] =09at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.j= ava:717) [java] =09at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.jav= a:605) [java] =09at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(Session= Impl.java:1202) [java] =09at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.ja= va:88) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :258) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :298) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :341) [java] =09at net.sf.hibernate.impl.SessionImpl.preFlushEntities(Ses= sionImpl.java:2285) [java] =09at net.sf.hibernate.impl.SessionImpl.flushEverything(Sess= ionImpl.java:2015) [java] =09at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.ja= va:2004) [java] =09at net.sf.hibernate.transaction.JDBCTransaction.commit(JD= BCTransaction.java:57) [java] =09at com.paraware.TestHibernate.main(TestHibernate.java:42) [java] CA 2193 main WARN net.sf.hibernate.util.JD= BCExceptionReporter - SQL Error: -803, SQLState: 23505 [java] CA 2193 main ERROR net.sf.hibernate.util.JD= BCExceptionReporter - [IBM][CLI Driver][DB2/NT] SQL0803N One or more valu= es in the INSERT statement, UPDATE statement, or foreign key update caused = by a DELETE statement are not valid because the primary key, unique constra= int or unique index identified by "1" constrains table "USER.CHILDREN" from= having duplicate rows for those columns. SQLSTATE=3D23505 [java]=20 [java] CA 2213 main DEBUG net.sf.hibernate.impl.Ba= tcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets [java] CA 2213 main DEBUG net.sf.hibernate.impl.Se= ssionFactoryImpl - closing statement [java] CA 2223 main ERROR net.sf.hibernate.util.JD= BCExceptionReporter - Could not insert [java] COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL= 0803N One or more values in the INSERT statement, UPDATE statement, or for= eign key update caused by a DELETE statement are not valid because the prim= ary key, unique constraint or unique index identified by "1" constrains tab= le "USER.CHILDREN" from having duplicate rows for those columns. SQLSTATE= =3D23505 [java]=20 [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:269) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:206) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_retur= n_code(SQLExceptionGenerator.java:457) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2= PreparedStatement.java:1429) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdat= e(DB2PreparedStatement.java:1021) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:504) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:444) [java] =09at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.j= ava:717) [java] =09at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.jav= a:605) [java] =09at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(Session= Impl.java:1202) [java] =09at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.ja= va:88) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :258) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :298) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :341) [java] =09at net.sf.hibernate.impl.SessionImpl.preFlushEntities(Ses= sionImpl.java:2285) [java] =09at net.sf.hibernate.impl.SessionImpl.flushEverything(Sess= ionImpl.java:2015) [java] =09at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.ja= va:2004) [java] =09at net.sf.hibernate.transaction.JDBCTransaction.commit(JD= BCTransaction.java:57) [java] =09at com.paraware.TestHibernate.main(TestHibernate.java:42) [java] CA 2314 main DEBUG net.sf.hibernate.impl.Se= ssionImpl - transaction completion [java] COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL= 0803N One or more values in the INSERT statement, UPDATE statement, or for= eign key update caused by a DELETE statement are not valid because the prim= ary key, unique constraint or unique index identified by "1" constrains tab= le "USER.CHILDREN" from having duplicate rows for those columns. SQLSTATE= =3D23505 [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:269) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:206) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_retur= n_code(SQLExceptionGenerator.java:457) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2= PreparedStatement.java:1429) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdat= e(DB2PreparedStatement.java:1021) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:504) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:444) [java] =09at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.j= ava:717) [java] =09at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.jav= a:605) [java] =09at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(Session= Impl.java:1202) [java] =09at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.ja= va:88) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :258) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :298) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :341) [java] =09at net.sf.hibernate.impl.SessionImpl.preFlushEntities(Ses= sionImpl.java:2285) [java] =09at net.sf.hibernate.impl.SessionImpl.flushEverything(Sess= ionImpl.java:2015) [java] =09at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.ja= va:2004) [java] =09at net.sf.hibernate.transaction.JDBCTransaction.commit(JD= BCTransaction.java:57) [java] =09at com.paraware.TestHibernate.main(TestHibernate.java:42) [java] rethrown as net.sf.hibernate.JDBCException: Could not insert= : [IBM][CLI Driver][DB2/NT] SQL0803N One or more values in the INSERT stat= ement, UPDATE statement, or foreign key update caused by a DELETE statement= are not valid because the primary key, unique constraint or unique index i= dentified by "1" constrains table "USER.CHILDREN" from having duplicate row= s for those columns. SQLSTATE=3D23505 [java] =09at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.j= ava:720) [java] =09at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.jav= a:605) [java] =09at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(Session= Impl.java:1202) [java] =09at net.sf.hibernate.engine.Cascades$3.cascade(Cascades.ja= va:88) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :258) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :298) [java] =09at net.sf.hibernate.engine.Cascades.cascade(Cascades.java= :341) [java] =09at net.sf.hibernate.impl.SessionImpl.preFlushEntities(Ses= sionImpl.java:2285) [java] =09at net.sf.hibernate.impl.SessionImpl.flushEverything(Sess= ionImpl.java:2015) [java] =09at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.ja= va:2004) [java] =09at net.sf.hibernate.transaction.JDBCTransaction.commit(JD= BCTransaction.java:57) [java] =09at com.paraware.TestHibernate.main(TestHibernate.java:42) [java] Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][= DB2/NT] SQL0803N One or more values in the INSERT statement, UPDATE statem= ent, or foreign key update caused by a DELETE statement are not valid becau= se the primary key, unique constraint or unique index identified by "1" con= strains table "USER.CHILDREN" from having duplicate rows for those columns.= SQLSTATE=3D23505 [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:269) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLEx= ception(SQLExceptionGenerator.java:206) [java] =09at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_retur= n_code(SQLExceptionGenerator.java:457) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2= PreparedStatement.java:1429) [java] =09at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdat= e(DB2PreparedStatement.java:1021) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:504) [java] =09at net.sf.hibernate.persister.EntityPersister.insert(Enti= tyPersister.java:444) [java] =09at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.j= ava:717) [java] =09... 11 more [java] Exception in thread "main"=20 [java] Java Result: 1 BUILD SUCCESSFUL Total time: 3 seconds --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?= key=3DHB-362 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-362 Summary: Save with native ID on DB2 fails with duplicate row exception = if data inserted behind hibernate Type: Bug Status: Unassigned Priority: Critical Project: Hibernate2 Versions: 2.0.3 Assignee:=20 Reporter: Brian Bonner Created: Thu, 25 Sep 2003 11:53 AM Updated: Thu, 25 Sep 2003 11:58 AM Environment: Win 2K SP4, JDK 1.4.2, Hibernate 2.0.3, DB2 7.2 UDB Description: If we restart the database manager (clean state), then execute the DDL generated by hibernate, and run the test case: TestHibernate records are inserted without problem. W= e can rerun the test case numerous times. If we restart the database manager, then insert data from a command line (behind hibernate): insert into parents values(1,'test','test','test','test',current timestamp)= ; insert into children values (1,'bb','1); insert into children values (2,'cc','1); and run the test case, it fails. hibernate.properties, Mapping, generated DDL, Domain Source, Test Source fo= llows. hibernate.connection.driver_class =3D COM.ibm.db2.jdbc.app.DB2Driver hibernate.dialect =3D net.sf.hibernate.dialect.DB2Dialect hibernate.connection.url =3D jdbc:db2:sample hibernate.connection.username =3D xyz hibernate.connection.password =3D pdq <?xml version=3D"1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> =09<class name=3D"com.paraware.domain.Parent" table=3D"parents"> =09=09<id name=3D"keyId" type=3D"int" unsaved-value=3D"0"> =09=09=09<column name=3D"key_id" not-null=3D"true"/> =09=09=09<generator class=3D"native"/> =09=09</id> =09=09<property name=3D"userID" column=3D"LogonID" type=3D"string"/> =09=09<property name=3D"userName" column=3D"Name" type=3D"string"/> =09=09<property name=3D"password" type=3D"string"/> =09=09<property name=3D"emailAddress" type=3D"string"/> =09=09<property name=3D"lastLogon" type=3D"timestamp"/> =09=09 =09=09<set name=3D"children" table=3D"children" cascade=3D"all" lazy=3D"tru= e" inverse=3D"true"> =09=09=09<key column=3D"key_id"/> =09=09=09<one-to-many class=3D"com.paraware.domain.Child"/> =09=09</set> =09</class> </hibernate-mapping> <?xml version=3D"1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> =09<class name=3D"com.paraware.domain.Child" table=3D"children"> =09=09 =09=09<id name=3D"mouseId" type=3D"int" unsaved-value=3D"0"> =09=09=09<column name=3D"mouse_id" not-null=3D"true"/> =09=09=09<generator class=3D"native"/> =09=09</id> =09=09 =09=09<property name=3D"name" column=3D"name" type=3D"string"/> =09=09 =09=09<many-to-one name=3D"parent" class=3D"com.paraware.domain.Parent" col= umn=3D"key_id" /> =09=09 =09</class> </hibernate-mapping> drop table parents; drop table children; create table parents ( key_id INTEGER not null generated by default as identity, LogonID VARCHAR(255), Name VARCHAR(255), password VARCHAR(255), emailAddress VARCHAR(255), lastLogon TIMESTAMP, primary key (key_id) ); create table children ( mouse_id INTEGER not null generated by default as identity, name VARCHAR(255), key_id INTEGER, primary key (mouse_id) ); alter table children add constraint FK62EA5DFFBC5E42FB foreign key (key_id)= references parents; package com.paraware.domain; import java.util.Date; import java.util.Set; // ... public class Parent { private int keyId; private String userID; private String userName; private String password; private String emailAddress; private Date lastLogon; private Set children; public int getKeyId() { return keyId; } public void setKeyId(int keyId) { this.keyId =3D keyId; } public String getUserID() { return userID; } public void setUserID(String newUserID) { userID =3D newUserID; } public String getUserName() { return userName; } public void setUserName(String newUserName) { userName =3D newUserName; } public String getPassword() { return password; } public void setPassword(String newPassword) { password =3D newPassword; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String newEmailAddress) { emailAddress =3D newEmailAddress; } public Date getLastLogon() { return lastLogon; } public void setLastLogon(Date newLastLogon) { lastLogon =3D newLastLogon; } public Set getChildren() { return children; } public void setChildren(Set mouses) { this.children =3D mouses; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this =3D=3D obj) return true; if ((obj =3D=3D null) || (obj.getClass() !=3D this.getClass())) return false; // Must be the Parent Parent other =3D (Parent) obj; return userID =3D=3D other.userID || userID !=3D null && userID.equals(other.userID) && userName =3D=3D other.userName || userName !=3D null && userName.equals(other.userName); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result =3D 17; result =3D userID =3D=3D null ? result : 37 * result + userID.hashCode(= ); result =3D userName =3D=3D null ? result : 37 * result + userName.hashC= ode(); return result; } } package com.paraware.domain; public class Child { private int mouseId; private String name; private Parent parent; public int getMouseId() { return mouseId; } public void setMouseId(int id) { this.mouseId =3D id; } public String getName() { return name; } public void setName(String newName) { name =3D newName; } public Parent getParent() { return parent; } public void setParent(Parent newUser) { parent =3D newUser; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this =3D=3D obj) return true; if ((obj =3D=3D null) || (obj.getClass() !=3D this.getClass())) return false; // Must be the Child Child other =3D (Child) obj; return name =3D=3D other.name || name !=3D null && name.equals(other.na= me); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result =3D 17; result =3D name =3D=3D null ? result : 37 * result + name.hashCode(); return result; } } package com.paraware; import java.sql.SQLException; import java.util.Date; import java.util.HashSet; import java.util.Set; import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.Transaction; import net.sf.hibernate.cfg.Configuration; import com.paraware.domain.Child; import com.paraware.domain.Parent; public class TestHibernate { public static void main(String args[]) throws HibernateException, SQLExce= ption { SessionFactory sessionFactory; Transaction transaction; Configuration cfg =3D new Configuration(); cfg.addClass(Parent.class); cfg.addClass(Child.class); sessionFactory =3D cfg.buildSessionFactory(); Session session =3D sessionFactory.openSession(); transaction =3D session.beginTransaction(); Parent newUser =3D new Parent(); newUser.setUserID("bnnn"); newUser.setUserName("Vivi"); newUser.setPassword("abcff"); newUser.setEmailAddress("vi...@co..."); newUser.setLastLogon(new Date()); session.save(newUser); Child ms1 =3D new Child(); ms1.setName("Mickey"); Child ms2 =3D new Child(); ms2.setName("Mouse"); Set mouseSet =3D new HashSet(); mouseSet.add(ms1); mouseSet.add(ms2); //set up association newUser.setChildren(mouseSet); //save foreign keys ms1.setParent(newUser); ms2.setParent(newUser); transaction.commit(); // close our session and release resources session.flush(); session.close(); } } --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-09-25 22:13:55
|
The following comment has been added to this issue: Author: Brian Bonner Created: Thu, 25 Sep 2003 5:13 PM Body: Gavin, I will pursue with IBM. I wrote a test case with a similar result. I create the tables, I insert the values: insert into parents values(1,'test','test','test','test',current timestamp); insert into children values (1,'bb',1); insert into children values (2,'cc',1); and then I run: package com.paraware; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; import java.util.Date; /** * */ public class TestDB2 { /** * */ public TestDB2() { super(); // TODO Auto-generated constructor stub } public static void main(String[] args) { try { Driver driver = (Driver) Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection("jdbc:db2:pbbtest", "user", "demo"); conn.setAutoCommit(false); conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); PreparedStatement stmt = conn.prepareStatement( "insert into parents (LogonID, Name, password, emailAddress, lastLogon, key_id) values (?, ?, ?, ?, ?, default)"); stmt.setString(1, "bnnn"); stmt.setString(2, "Vivi"); stmt.setString(3, "abcff"); stmt.setString(4, "vi...@co...m"); stmt.setTimestamp(5, new Timestamp(new Date().getTime())); stmt.executeUpdate(); stmt.close(); conn.commit(); conn.close(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } } and bang: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "USER.PARENTS" from having duplicate rows for those columns. SQLSTATE=23505 at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:269) at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:206) at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGenerator.java:457) at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2PreparedStatement.java:1429) at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(DB2PreparedStatement.java:1021) at com.paraware.TestDB2.main(TestDB2.java:38) I'll open up a PMR with them on this. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-362 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-362 Summary: Save with native ID on DB2 fails with duplicate row exception if data inserted behind hibernate Type: Bug Status: Closed Priority: Critical Resolution: REJECTED Project: Hibernate2 Versions: 2.0.3 Assignee: Reporter: Brian Bonner Created: Thu, 25 Sep 2003 11:53 AM Updated: Thu, 25 Sep 2003 3:39 PM Environment: Win 2K SP4, JDK 1.4.2, Hibernate 2.0.3, DB2 7.2 UDB Description: If we restart the database manager (clean state), then execute the DDL generated by hibernate, and run the test case: TestHibernate records are inserted without problem. We can rerun the test case numerous times. If we restart the database manager, then insert data from a command line (behind hibernate): insert into parents values(1,'test','test','test','test',current timestamp); insert into children values (1,'bb','1); insert into children values (2,'cc','1); and run the test case, it fails. hibernate.properties, Mapping, generated DDL, Domain Source, Test Source follows. hibernate.connection.driver_class = COM.ibm.db2.jdbc.app.DB2Driver hibernate.dialect = net.sf.hibernate.dialect.DB2Dialect hibernate.connection.url = jdbc:db2:sample hibernate.connection.username = xyz hibernate.connection.password = pdq <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.paraware.domain.Parent" table="parents"> <id name="keyId" type="int" unsaved-value="0"> <column name="key_id" not-null="true"/> <generator class="native"/> </id> <property name="userID" column="LogonID" type="string"/> <property name="userName" column="Name" type="string"/> <property name="password" type="string"/> <property name="emailAddress" type="string"/> <property name="lastLogon" type="timestamp"/> <set name="children" table="children" cascade="all" lazy="true" inverse="true"> <key column="key_id"/> <one-to-many class="com.paraware.domain.Child"/> </set> </class> </hibernate-mapping> <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.paraware.domain.Child" table="children"> <id name="mouseId" type="int" unsaved-value="0"> <column name="mouse_id" not-null="true"/> <generator class="native"/> </id> <property name="name" column="name" type="string"/> <many-to-one name="parent" class="com.paraware.domain.Parent" column="key_id" /> </class> </hibernate-mapping> drop table parents; drop table children; create table parents ( key_id INTEGER not null generated by default as identity, LogonID VARCHAR(255), Name VARCHAR(255), password VARCHAR(255), emailAddress VARCHAR(255), lastLogon TIMESTAMP, primary key (key_id) ); create table children ( mouse_id INTEGER not null generated by default as identity, name VARCHAR(255), key_id INTEGER, primary key (mouse_id) ); alter table children add constraint FK62EA5DFFBC5E42FB foreign key (key_id) references parents; package com.paraware.domain; import java.util.Date; import java.util.Set; // ... public class Parent { private int keyId; private String userID; private String userName; private String password; private String emailAddress; private Date lastLogon; private Set children; public int getKeyId() { return keyId; } public void setKeyId(int keyId) { this.keyId = keyId; } public String getUserID() { return userID; } public void setUserID(String newUserID) { userID = newUserID; } public String getUserName() { return userName; } public void setUserName(String newUserName) { userName = newUserName; } public String getPassword() { return password; } public void setPassword(String newPassword) { password = newPassword; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String newEmailAddress) { emailAddress = newEmailAddress; } public Date getLastLogon() { return lastLogon; } public void setLastLogon(Date newLastLogon) { lastLogon = newLastLogon; } public Set getChildren() { return children; } public void setChildren(Set mouses) { this.children = mouses; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if ((obj == null) || (obj.getClass() != this.getClass())) return false; // Must be the Parent Parent other = (Parent) obj; return userID == other.userID || userID != null && userID.equals(other.userID) && userName == other.userName || userName != null && userName.equals(other.userName); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result = 17; result = userID == null ? result : 37 * result + userID.hashCode(); result = userName == null ? result : 37 * result + userName.hashCode(); return result; } } package com.paraware.domain; public class Child { private int mouseId; private String name; private Parent parent; public int getMouseId() { return mouseId; } public void setMouseId(int id) { this.mouseId = id; } public String getName() { return name; } public void setName(String newName) { name = newName; } public Parent getParent() { return parent; } public void setParent(Parent newUser) { parent = newUser; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if ((obj == null) || (obj.getClass() != this.getClass())) return false; // Must be the Child Child other = (Child) obj; return name == other.name || name != null && name.equals(other.name); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result = 17; result = name == null ? result : 37 * result + name.hashCode(); return result; } } package com.paraware; import java.sql.SQLException; import java.util.Date; import java.util.HashSet; import java.util.Set; import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.Transaction; import net.sf.hibernate.cfg.Configuration; import com.paraware.domain.Child; import com.paraware.domain.Parent; public class TestHibernate { public static void main(String args[]) throws HibernateException, SQLException { SessionFactory sessionFactory; Transaction transaction; Configuration cfg = new Configuration(); cfg.addClass(Parent.class); cfg.addClass(Child.class); sessionFactory = cfg.buildSessionFactory(); Session session = sessionFactory.openSession(); transaction = session.beginTransaction(); Parent newUser = new Parent(); newUser.setUserID("bnnn"); newUser.setUserName("Vivi"); newUser.setPassword("abcff"); newUser.setEmailAddress("vi...@co..."); newUser.setLastLogon(new Date()); session.save(newUser); Child ms1 = new Child(); ms1.setName("Mickey"); Child ms2 = new Child(); ms2.setName("Mouse"); Set mouseSet = new HashSet(); mouseSet.add(ms1); mouseSet.add(ms2); //set up association newUser.setChildren(mouseSet); //save foreign keys ms1.setParent(newUser); ms2.setParent(newUser); transaction.commit(); // close our session and release resources session.flush(); session.close(); } } --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-09-25 22:26:54
|
The following comment has been added to this issue: Author: Brian Bonner Created: Thu, 25 Sep 2003 5:26 PM Body: I did research on the knowledgebase. Apparently, there is an item in the support database that is close: http://www-1.ibm.com/support/docview.wss?rs=0&context=SSEPGG&q=%2bidentity&uid=swg21007891&loc=en_US&cs=utf-8&cc=US&lang=en ALTER TABLE <table> ALTER COLUMN <id col> RESTART WITH <nextval> So in my example: After I do my inserts from the CLP, if I execute: ALTER TABLE PARENTS ALTER COLUMN KEY_ID RESTART WITH 500 Hibernate will start with 500. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-362 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-362 Summary: Save with native ID on DB2 fails with duplicate row exception if data inserted behind hibernate Type: Bug Status: Closed Priority: Critical Resolution: REJECTED Project: Hibernate2 Versions: 2.0.3 Assignee: Reporter: Brian Bonner Created: Thu, 25 Sep 2003 11:53 AM Updated: Thu, 25 Sep 2003 3:39 PM Environment: Win 2K SP4, JDK 1.4.2, Hibernate 2.0.3, DB2 7.2 UDB Description: If we restart the database manager (clean state), then execute the DDL generated by hibernate, and run the test case: TestHibernate records are inserted without problem. We can rerun the test case numerous times. If we restart the database manager, then insert data from a command line (behind hibernate): insert into parents values(1,'test','test','test','test',current timestamp); insert into children values (1,'bb','1); insert into children values (2,'cc','1); and run the test case, it fails. hibernate.properties, Mapping, generated DDL, Domain Source, Test Source follows. hibernate.connection.driver_class = COM.ibm.db2.jdbc.app.DB2Driver hibernate.dialect = net.sf.hibernate.dialect.DB2Dialect hibernate.connection.url = jdbc:db2:sample hibernate.connection.username = xyz hibernate.connection.password = pdq <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.paraware.domain.Parent" table="parents"> <id name="keyId" type="int" unsaved-value="0"> <column name="key_id" not-null="true"/> <generator class="native"/> </id> <property name="userID" column="LogonID" type="string"/> <property name="userName" column="Name" type="string"/> <property name="password" type="string"/> <property name="emailAddress" type="string"/> <property name="lastLogon" type="timestamp"/> <set name="children" table="children" cascade="all" lazy="true" inverse="true"> <key column="key_id"/> <one-to-many class="com.paraware.domain.Child"/> </set> </class> </hibernate-mapping> <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="com.paraware.domain.Child" table="children"> <id name="mouseId" type="int" unsaved-value="0"> <column name="mouse_id" not-null="true"/> <generator class="native"/> </id> <property name="name" column="name" type="string"/> <many-to-one name="parent" class="com.paraware.domain.Parent" column="key_id" /> </class> </hibernate-mapping> drop table parents; drop table children; create table parents ( key_id INTEGER not null generated by default as identity, LogonID VARCHAR(255), Name VARCHAR(255), password VARCHAR(255), emailAddress VARCHAR(255), lastLogon TIMESTAMP, primary key (key_id) ); create table children ( mouse_id INTEGER not null generated by default as identity, name VARCHAR(255), key_id INTEGER, primary key (mouse_id) ); alter table children add constraint FK62EA5DFFBC5E42FB foreign key (key_id) references parents; package com.paraware.domain; import java.util.Date; import java.util.Set; // ... public class Parent { private int keyId; private String userID; private String userName; private String password; private String emailAddress; private Date lastLogon; private Set children; public int getKeyId() { return keyId; } public void setKeyId(int keyId) { this.keyId = keyId; } public String getUserID() { return userID; } public void setUserID(String newUserID) { userID = newUserID; } public String getUserName() { return userName; } public void setUserName(String newUserName) { userName = newUserName; } public String getPassword() { return password; } public void setPassword(String newPassword) { password = newPassword; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String newEmailAddress) { emailAddress = newEmailAddress; } public Date getLastLogon() { return lastLogon; } public void setLastLogon(Date newLastLogon) { lastLogon = newLastLogon; } public Set getChildren() { return children; } public void setChildren(Set mouses) { this.children = mouses; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if ((obj == null) || (obj.getClass() != this.getClass())) return false; // Must be the Parent Parent other = (Parent) obj; return userID == other.userID || userID != null && userID.equals(other.userID) && userName == other.userName || userName != null && userName.equals(other.userName); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result = 17; result = userID == null ? result : 37 * result + userID.hashCode(); result = userName == null ? result : 37 * result + userName.hashCode(); return result; } } package com.paraware.domain; public class Child { private int mouseId; private String name; private Parent parent; public int getMouseId() { return mouseId; } public void setMouseId(int id) { this.mouseId = id; } public String getName() { return name; } public void setName(String newName) { name = newName; } public Parent getParent() { return parent; } public void setParent(Parent newUser) { parent = newUser; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if ((obj == null) || (obj.getClass() != this.getClass())) return false; // Must be the Child Child other = (Child) obj; return name == other.name || name != null && name.equals(other.name); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { int result = 17; result = name == null ? result : 37 * result + name.hashCode(); return result; } } package com.paraware; import java.sql.SQLException; import java.util.Date; import java.util.HashSet; import java.util.Set; import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; import net.sf.hibernate.Transaction; import net.sf.hibernate.cfg.Configuration; import com.paraware.domain.Child; import com.paraware.domain.Parent; public class TestHibernate { public static void main(String args[]) throws HibernateException, SQLException { SessionFactory sessionFactory; Transaction transaction; Configuration cfg = new Configuration(); cfg.addClass(Parent.class); cfg.addClass(Child.class); sessionFactory = cfg.buildSessionFactory(); Session session = sessionFactory.openSession(); transaction = session.beginTransaction(); Parent newUser = new Parent(); newUser.setUserID("bnnn"); newUser.setUserName("Vivi"); newUser.setPassword("abcff"); newUser.setEmailAddress("vi...@co..."); newUser.setLastLogon(new Date()); session.save(newUser); Child ms1 = new Child(); ms1.setName("Mickey"); Child ms2 = new Child(); ms2.setName("Mouse"); Set mouseSet = new HashSet(); mouseSet.add(ms1); mouseSet.add(ms2); //set up association newUser.setChildren(mouseSet); //save foreign keys ms1.setParent(newUser); ms2.setParent(newUser); transaction.commit(); // close our session and release resources session.flush(); session.close(); } } --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |