I have Mitarbeiter (employee) objects connected to Projekt (project) objects via MaPro objects, which are pure associative entities with a foreign from both Mitarbeiter and Projekt.
Mitarbeiter -> MaPro <- Projekt
I want to replicate a Mitarbeiter m with all connected objects to another database, so I fetch a Mitarbeiter instance with lazy="false", discard the session, open a new one to another database and do a session.replicate(m, ReplicationMode.OVERWRITE).
for the _projektSet in Mitarbeiter and the _mitarbeiterSet in Projekt cascade is set to "all".
When replicate()ing, I see inserts coming for one Mitarbeiter and two Projects (whichs is correct), but then hibernate tries to insert the associative MaPro Objects two times - I'd believe it tries to persist the sets from both directions.
Hibernate Version is 2.1.4, source objects are fetched from ORACLE 8 via the ORACLE 10g JDBC drivers and replicated into MySQL 4.0.20a via their official JDBC drivers. Mapping files are, of course, the same for both.
Here are the mappings:
Code:
<class name="Mitarbeiter" table="MITARBEITER">
<id
column="ID"
name="id"
type="string"
>
<generator class="net.sf.hibernate.id.UUIDHexGenerator" />
</id>
<property
column="AGE"
length="3"
name="age"
not-null="false"
type="integer"
/>
<property
column="FAMILIENNAME"
length="50"
name="familienname"
not-null="false"
type="string"
/>
<property
column="VORNAME"
length="50"
name="vorname"
not-null="false"
type="string"
/>
<set
cascade="all"
lazy="true"
name="projektSet"
table="MA_PRO"
>
<key column="MA" />
<many-to-many class="Projekt" column="PRO" />
</set>
</class>
<class name="Projekt" table="PROJEKT">
<id
column="ID"
name="id"
type="string"
>
<generator class="net.sf.hibernate.id.UUIDHexGenerator" />
</id>
<property
column="ENDE"
length="7"
name="ende"
not-null="false"
type="date"
/>
<property
column="BEGINN"
length="7"
name="beginn"
not-null="false"
type="date"
/>
<property
column="BEZEICHUNG"
length="128"
name="bezeichung"
not-null="false"
type="string"
/>
<set
cascade="all"
lazy="true"
name="mitarbeiterSet"
table="MA_PRO"
>
<key column="PRO" />
<many-to-many class="Mitarbeiter" column="MA" />
</set>
</class>
<class name="MaPro" table="MA_PRO">
<composite-id>
<key-many-to-one
class="Mitarbeiter"
column="MA"
name="ma"
/>
<key-many-to-one
class="Projekt"
column="PRO"
name="pro"
/>
</composite-id>
</class>
and this is the trace output:
Code:
00:35:05,133 INFO Environment:462 - Hibernate 2.1.4
00:35:05,143 INFO Environment:491 - hibernate.properties not found
00:35:05,143 INFO Environment:522 - using CGLIB reflection optimizer
00:35:05,153 INFO Configuration:906 - configuring from file: hibernate-mysql.cfg.xml
00:35:05,244 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd in classpath under net/sf/hibernate/
00:35:05,244 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd in classpath
00:35:05,304 DEBUG Configuration:830 - hibernate.connection.url=jdbc:mysql://localhost/xxx
00:35:05,304 DEBUG Configuration:830 - hibernate.connection.driver_class=com.mysql.jdbc.Driver
00:35:05,314 DEBUG Configuration:830 - hibernate.connection.username=xxx
00:35:05,314 DEBUG Configuration:830 - hibernate.connection.password=xxx
00:35:05,314 DEBUG Configuration:830 - dialect=net.sf.hibernate.dialect.MySQLDialect
00:35:05,314 DEBUG Configuration:830 - hibernate.show_sql=true
00:35:05,314 DEBUG Configuration:830 - hibernate.use_outer_join=true
00:35:05,314 DEBUG Configuration:830 - hibernate.jdbc.batch_size=3
00:35:05,314 DEBUG Configuration:998 - null<-org.dom4j.tree.DefaultAttribute@c832d2 [Attribute: name file value "Mitarbeiter.hbm"]
00:35:05,314 INFO Configuration:166 - Mapping file: Mitarbeiter.hbm
00:35:05,324 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
00:35:05,324 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
00:35:05,484 INFO Binder:229 - Mapping class: demo.db.Mitarbeiter -> MITARBEITER
00:35:05,594 DEBUG Binder:475 - Mapped property: id -> ID, type: string
00:35:05,624 DEBUG Binder:475 - Mapped property: age -> AGE, type: integer
00:35:05,624 DEBUG Binder:475 - Mapped property: familienname -> FAMILIENNAME, type: string
00:35:05,624 DEBUG Binder:475 - Mapped property: vorname -> VORNAME, type: string
00:35:05,624 INFO Binder:560 - Mapping collection: demo.db.Mitarbeiter.projektSet -> MA_PRO
00:35:05,634 DEBUG Binder:475 - Mapped property: projektSet, type: java.util.Set
00:35:05,634 DEBUG Configuration:998 - null<-org.dom4j.tree.DefaultAttribute@19d0a1 [Attribute: name file value "Projekt.hbm"]
00:35:05,634 INFO Configuration:166 - Mapping file: Projekt.hbm
00:35:05,634 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
00:35:05,644 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
00:35:05,684 INFO Binder:229 - Mapping class: demo.db.Projekt -> PROJEKT
00:35:05,684 DEBUG Binder:475 - Mapped property: id -> ID, type: string
00:35:05,684 DEBUG Binder:475 - Mapped property: ende -> ENDE, type: date
00:35:05,684 DEBUG Binder:475 - Mapped property: beginn -> BEGINN, type: date
00:35:05,684 DEBUG Binder:475 - Mapped property: bezeichung -> BEZEICHUNG, type: string
00:35:05,684 INFO Binder:560 - Mapping collection: demo.db.Projekt.mitarbeiterSet -> MA_PRO
00:35:05,684 DEBUG Binder:475 - Mapped property: mitarbeiterSet, type: java.util.Set
00:35:05,684 DEBUG Configuration:998 - null<-org.dom4j.tree.DefaultAttribute@12bb7e0 [Attribute: name file value "MaPro.hbm"]
00:35:05,684 INFO Configuration:166 - Mapping file: MaPro.hbm
00:35:05,694 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
00:35:05,694 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
00:35:05,754 INFO Binder:229 - Mapping class: demo.db.MaPro -> MA_PRO
00:35:05,764 DEBUG Binder:475 - Mapped property: ma -> MA, type: demo.db.Mitarbeiter
00:35:05,764 DEBUG Binder:475 - Mapped property: pro -> PRO, type: demo.db.Projekt
00:35:06,045 INFO Configuration:1030 - Configured SessionFactory: null
00:35:06,045 DEBUG Configuration:1031 - properties: {hibernate.connection.password=xxx, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Programme\Java\j2re1.4.2_03\bin, java.vm.version=1.4.2_03-b02, hibernate.connection.username=xxx, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=AT, sun.os.patch.level=Service Pack 1, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Programme\eclipse2_1_3\workspace\Demo, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Programme\Java\j2re1.4.2_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOKUME~1\sagajsc.EUR\LOKALE~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Programme\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\PROGRAMME\THINKPAD\UTILITIES;C:\oracle\ora81\bin;C:\Programme\Oracle\jre\1.1.7\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\UltraEdit;%ADAPATH%;%ADADIR%\%ADAVERS%;%ADADIR%\%ADAVERS%\tools;C:\Programme\Microsoft SQL Server\80\Tools\Binn\;C:\Programme\ATI Technologies\ATI Control Panel;C:\Programme\ATI Technologies\Fire GL 3D Studio Max;C:\Programme\ATI Technologies\Fire GL Control Panel;C:\Enabler\Runtime;;C:\jwsdp-1.3\jwsdp-shared\bin;C:\jwsdp-1.3\jwsdp-shared\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Dokumente und Einstellungen\sagajsc.EUR, user.timezone=Europe/Berlin, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=sagajsc, java.class.path=C:\Programme\eclipse2_1_3\workspace\Demo;C:\Programme\eclipse2_1_3\workspace\Library;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\pf-joi-full.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\bsh-2.0b1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\cglib-full-2.0.1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\commons-collections-2.1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\commons-logging-1.0.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\dom4j-1.4.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\ehcache-0.8.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\forms-1.0.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\hibern8ide.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\hibernate2.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jdbc2_0-stdext.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jgraph.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\JSX2.2.2.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jta.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\log4j-1.2.8.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\looks-1.1.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\mysql-connector-java-3.0.14-production-bin.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\odmg-3.0.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\ojdbc14.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Programme\Java\j2re1.4.2_03, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/xxx, user.language=de, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_03, java.ext.dirs=C:\Programme\Java\j2re1.4.2_03\lib\ext, sun.boot.class.path=C:\Programme\Java\j2re1.4.2_03\lib\rt.jar;C:\Programme\Java\j2re1.4.2_03\lib\i18n.jar;C:\Programme\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Programme\Java\j2re1.4.2_03\lib\jsse.jar;C:\Programme\Java\j2re1.4.2_03\lib\jce.jar;C:\Programme\Java\j2re1.4.2_03\lib\charsets.jar;C:\Programme\Java\j2re1.4.2_03\classes, java.vendor=Sun Microsystems Inc., hibernate.jdbc.batch_size=3, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, hibernate.use_outer_join=true, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=pentium i486 i386}
00:35:06,045 INFO Configuration:613 - processing one-to-many association mappings
00:35:06,045 DEBUG Binder:1340 - Second pass for collection: demo.db.Mitarbeiter.projektSet
00:35:06,055 DEBUG Binder:1355 - Mapped collection key: MA, element: PRO, type: demo.db.Projekt
00:35:06,055 DEBUG Binder:1340 - Second pass for collection: demo.db.Projekt.mitarbeiterSet
00:35:06,055 DEBUG Binder:1355 - Mapped collection key: PRO, element: MA, type: demo.db.Mitarbeiter
00:35:06,065 INFO Configuration:622 - processing one-to-one association property references
00:35:06,065 INFO Configuration:647 - processing foreign key constraints
00:35:06,065 DEBUG Configuration:657 - resolving reference to class: demo.db.Mitarbeiter
00:35:06,065 DEBUG Configuration:657 - resolving reference to class: demo.db.Projekt
00:35:06,095 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
00:35:06,105 INFO SettingsFactory:62 - Use outer join fetching: true
00:35:06,105 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
00:35:06,115 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
00:35:06,115 INFO DriverManagerConnectionProvider:77 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/xxx
00:35:06,125 INFO DriverManagerConnectionProvider:78 - connection properties: {user=xxx, password=xxx}
00:35:06,135 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
00:35:06,135 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
00:35:06,135 DEBUG DriverManagerConnectionProvider:100 - opening new JDBC connection
00:35:06,415 DEBUG DriverManagerConnectionProvider:106 - created connection to: jdbc:mysql://localhost/xxx, Isolation Level: 4
00:35:06,425 DEBUG DriverManagerConnectionProvider:120 - returning connection to pool, pool size: 1
00:35:06,425 INFO SettingsFactory:102 - Use scrollable result sets: true
00:35:06,425 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
00:35:06,425 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
00:35:06,425 INFO SettingsFactory:114 - echoing all SQL to stdout
00:35:06,425 INFO SettingsFactory:117 - Query language substitutions: {}
00:35:06,425 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
00:35:06,435 INFO Configuration:1093 - instantiating and configuring caches
00:35:06,475 INFO SessionFactoryImpl:119 - building session factory
00:35:06,475 DEBUG SessionFactoryImpl:125 - instantiating session factory with properties: {hibernate.connection.password=xxx, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\Programme\Java\j2re1.4.2_03\bin, java.vm.version=1.4.2_03-b02, hibernate.connection.username=xxx, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=AT, sun.os.patch.level=Service Pack 1, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Programme\eclipse2_1_3\workspace\Demo, java.runtime.version=1.4.2_03-b02, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Programme\Java\j2re1.4.2_03\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOKUME~1\sagajsc.EUR\LOKALE~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Programme\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\PROGRAMME\THINKPAD\UTILITIES;C:\oracle\ora81\bin;C:\Programme\Oracle\jre\1.1.7\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\UltraEdit;%ADAPATH%;%ADADIR%\%ADAVERS%;%ADADIR%\%ADAVERS%\tools;C:\Programme\Microsoft SQL Server\80\Tools\Binn\;C:\Programme\ATI Technologies\ATI Control Panel;C:\Programme\ATI Technologies\Fire GL 3D Studio Max;C:\Programme\ATI Technologies\Fire GL Control Panel;C:\Enabler\Runtime;;C:\jwsdp-1.3\jwsdp-shared\bin;C:\jwsdp-1.3\jwsdp-shared\bin, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Dokumente und Einstellungen\sagajsc.EUR, user.timezone=Europe/Berlin, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=com.mysql.jdbc.Driver, user.name=sagajsc, java.class.path=C:\Programme\eclipse2_1_3\workspace\Demo;C:\Programme\eclipse2_1_3\workspace\Library;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\pf-joi-full.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\bsh-2.0b1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\cglib-full-2.0.1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\commons-collections-2.1.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\commons-logging-1.0.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\dom4j-1.4.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\ehcache-0.8.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\forms-1.0.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\hibern8ide.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\hibernate2.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jdbc2_0-stdext.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jgraph.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\JSX2.2.2.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\jta.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\log4j-1.2.8.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\looks-1.1.3.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\mysql-connector-java-3.0.14-production-bin.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\odmg-3.0.jar;C:\Programme\eclipse2_1_3\workspace\Library\hibernate-lib\ojdbc14.jar, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Programme\Java\j2re1.4.2_03, sun.arch.data.model=32, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/xxx, user.language=de, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_03, java.ext.dirs=C:\Programme\Java\j2re1.4.2_03\lib\ext, sun.boot.class.path=C:\Programme\Java\j2re1.4.2_03\lib\rt.jar;C:\Programme\Java\j2re1.4.2_03\lib\i18n.jar;C:\Programme\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Programme\Java\j2re1.4.2_03\lib\jsse.jar;C:\Programme\Java\j2re1.4.2_03\lib\jce.jar;C:\Programme\Java\j2re1.4.2_03\lib\charsets.jar;C:\Programme\Java\j2re1.4.2_03\classes, java.vendor=Sun Microsystems Inc., hibernate.jdbc.batch_size=3, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, hibernate.use_outer_join=true, dialect=net.sf.hibernate.dialect.MySQLDialect, sun.cpu.isalist=pentium i486 i386}
00:35:06,886 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
00:35:06,896 DEBUG SessionFactoryObjectFactory:76 - registered: 40288083fd7cd8c300fd7cd8c5060000 (unnamed)
00:35:06,906 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
00:35:06,906 DEBUG SessionFactoryImpl:196 - instantiated session factory
00:35:06,986 DEBUG SessionImpl:555 - opened session
00:35:06,986 DEBUG JDBCTransaction:37 - begin
00:35:06,986 DEBUG DriverManagerConnectionProvider:84 - total checked-out connections: 0
00:35:06,996 DEBUG DriverManagerConnectionProvider:90 - using pooled JDBC connection, pool size: 0
00:35:06,996 DEBUG JDBCTransaction:41 - current autocommit status:false
00:35:07,006 DEBUG Cascades:341 - id unsaved-value strategy NULL
00:35:07,006 DEBUG AbstractEntityPersister:1136 - Getting version: [demo.db.Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,006 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,006 DEBUG SQL:237 - select ID from MITARBEITER where ID =?
Hibernate: select ID from MITARBEITER where ID =?
00:35:07,006 DEBUG BatcherImpl:241 - preparing statement
00:35:07,026 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 1
00:35:07,026 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,026 DEBUG BatcherImpl:261 - closing statement
00:35:07,026 DEBUG SessionImpl:3894 - replicating [demo.db.Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,026 DEBUG Cascades:497 - processing cascades for: demo.db.Mitarbeiter
00:35:07,036 DEBUG Cascades:506 - done processing cascades for: demo.db.Mitarbeiter
00:35:07,056 DEBUG SessionImpl:1286 - collection dereferenced while transient [demo.db.Mitarbeiter.projektSet#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,066 DEBUG Cascades:497 - processing cascades for: demo.db.Mitarbeiter
00:35:07,066 DEBUG Cascades:524 - cascading to collection: demo.db.Mitarbeiter.projektSet
00:35:07,066 DEBUG Cascades:146 - cascading to replicate()
00:35:07,066 DEBUG Cascades:341 - id unsaved-value strategy NULL
00:35:07,066 DEBUG AbstractEntityPersister:1136 - Getting version: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,066 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,076 DEBUG SQL:237 - select ID from PROJEKT where ID =?
Hibernate: select ID from PROJEKT where ID =?
00:35:07,076 DEBUG BatcherImpl:241 - preparing statement
00:35:07,076 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530002' to parameter: 1
00:35:07,076 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,076 DEBUG BatcherImpl:261 - closing statement
00:35:07,076 DEBUG SessionImpl:3894 - replicating [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,076 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,076 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,076 DEBUG SessionImpl:1286 - collection dereferenced while transient [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,076 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,076 DEBUG Cascades:524 - cascading to collection: demo.db.Projekt.mitarbeiterSet
00:35:07,076 DEBUG Cascades:146 - cascading to replicate()
00:35:07,076 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,076 DEBUG Cascades:146 - cascading to replicate()
00:35:07,086 DEBUG Cascades:341 - id unsaved-value strategy NULL
00:35:07,086 DEBUG AbstractEntityPersister:1136 - Getting version: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,086 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,086 DEBUG SQL:237 - select ID from PROJEKT where ID =?
Hibernate: select ID from PROJEKT where ID =?
00:35:07,086 DEBUG BatcherImpl:241 - preparing statement
00:35:07,086 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530003' to parameter: 1
00:35:07,086 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,086 DEBUG BatcherImpl:261 - closing statement
00:35:07,086 DEBUG SessionImpl:3894 - replicating [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,086 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,086 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,086 DEBUG SessionImpl:1286 - collection dereferenced while transient [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,086 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,086 DEBUG Cascades:524 - cascading to collection: demo.db.Projekt.mitarbeiterSet
00:35:07,086 DEBUG Cascades:146 - cascading to replicate()
00:35:07,086 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,086 DEBUG Cascades:506 - done processing cascades for: demo.db.Mitarbeiter
session.replicate(m, ReplicationMode.OVERWRITE)
00:35:07,096 DEBUG SessionImpl:2242 - flushing session
00:35:07,096 DEBUG Cascades:497 - processing cascades for: demo.db.Mitarbeiter
00:35:07,096 DEBUG Cascades:524 - cascading to collection: demo.db.Mitarbeiter.projektSet
00:35:07,096 DEBUG Cascades:113 - cascading to saveOrUpdate()
00:35:07,096 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
00:35:07,096 DEBUG Cascades:113 - cascading to saveOrUpdate()
00:35:07,096 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
00:35:07,096 DEBUG Cascades:506 - done processing cascades for: demo.db.Mitarbeiter
00:35:07,096 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,096 DEBUG Cascades:524 - cascading to collection: demo.db.Projekt.mitarbeiterSet
00:35:07,096 DEBUG Cascades:113 - cascading to saveOrUpdate()
00:35:07,106 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
00:35:07,106 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,106 DEBUG Cascades:497 - processing cascades for: demo.db.Projekt
00:35:07,106 DEBUG Cascades:524 - cascading to collection: demo.db.Projekt.mitarbeiterSet
00:35:07,106 DEBUG Cascades:113 - cascading to saveOrUpdate()
00:35:07,106 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
00:35:07,106 DEBUG Cascades:506 - done processing cascades for: demo.db.Projekt
00:35:07,106 DEBUG SessionImpl:2435 - Flushing entities and processing referenced collections
00:35:07,106 DEBUG SessionImpl:2880 - Collection found: [demo.db.Mitarbeiter.projektSet#40288ca8fd76c5ac00fd76c5ae350001], was: [<unreferenced>]
00:35:07,116 DEBUG SessionImpl:2880 - Collection found: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530002], was: [<unreferenced>]
00:35:07,116 DEBUG SessionImpl:2880 - Collection found: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530003], was: [<unreferenced>]
00:35:07,116 DEBUG SessionImpl:2776 - Processing unreferenced collections
00:35:07,116 DEBUG SessionImpl:2790 - Scheduling collection removes/(re)creates/updates
00:35:07,116 DEBUG SessionImpl:2266 - Flushed: 3 insertions, 0 updates, 0 deletions to 3 objects
00:35:07,116 DEBUG SessionImpl:2271 - Flushed: 3 (re)creations, 0 updates, 3 removals to 3 collections
00:35:07,116 DEBUG Printer:75 - listing entities:
00:35:07,126 DEBUG Printer:82 - demo.db.Mitarbeiter{age=44, projektSet=[Projekt#40288ca8fd76c5ac00fd76c5ae530002, Projekt#40288ca8fd76c5ac00fd76c5ae530003], familienname=Doe, vorname=John, id=40288ca8fd76c5ac00fd76c5ae350001}
00:35:07,186 DEBUG Printer:82 - demo.db.Projekt{beginn=30 Juni 2004, mitarbeiterSet=[Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001], ende=30 Juni 2004, id=40288ca8fd76c5ac00fd76c5ae530003, bezeichung=Project Teil 2}
00:35:07,186 DEBUG Printer:82 - demo.db.Projekt{beginn=30 Juni 2004, mitarbeiterSet=[Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001], ende=30 Juni 2004, id=40288ca8fd76c5ac00fd76c5ae530002, bezeichung=Project}
00:35:07,186 DEBUG SessionImpl:2355 - executing flush
00:35:07,186 DEBUG EntityPersister:453 - Inserting entity: [demo.db.Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,186 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,196 DEBUG SQL:237 - insert into MITARBEITER (AGE, FAMILIENNAME, VORNAME, ID) values (?, ?, ?, ?)
Hibernate: insert into MITARBEITER (AGE, FAMILIENNAME, VORNAME, ID) values (?, ?, ?, ?)
00:35:07,196 DEBUG BatcherImpl:241 - preparing statement
00:35:07,196 DEBUG EntityPersister:388 - Dehydrating entity: [demo.db.Mitarbeiter#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,196 DEBUG IntegerType:46 - binding '44' to parameter: 1
00:35:07,196 DEBUG StringType:46 - binding 'Doe' to parameter: 2
00:35:07,196 DEBUG StringType:46 - binding 'John' to parameter: 3
00:35:07,196 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 4
00:35:07,196 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,206 DEBUG EntityPersister:453 - Inserting entity: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,206 DEBUG BatcherImpl:50 - Executing batch size: 1
00:35:07,206 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,206 DEBUG BatcherImpl:261 - closing statement
00:35:07,206 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,206 DEBUG SQL:237 - insert into PROJEKT (ENDE, BEGINN, BEZEICHUNG, ID) values (?, ?, ?, ?)
Hibernate: insert into PROJEKT (ENDE, BEGINN, BEZEICHUNG, ID) values (?, ?, ?, ?)
00:35:07,206 DEBUG BatcherImpl:241 - preparing statement
00:35:07,206 DEBUG EntityPersister:388 - Dehydrating entity: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,206 DEBUG DateType:46 - binding '30 Juni 2004' to parameter: 1
00:35:07,206 DEBUG DateType:46 - binding '30 Juni 2004' to parameter: 2
00:35:07,216 DEBUG StringType:46 - binding 'Project' to parameter: 3
00:35:07,216 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530002' to parameter: 4
00:35:07,216 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,216 DEBUG EntityPersister:453 - Inserting entity: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,216 DEBUG EntityPersister:388 - Dehydrating entity: [demo.db.Projekt#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,216 DEBUG DateType:46 - binding '30 Juni 2004' to parameter: 1
00:35:07,216 DEBUG DateType:46 - binding '30 Juni 2004' to parameter: 2
00:35:07,216 DEBUG StringType:46 - binding 'Project Teil 2' to parameter: 3
00:35:07,216 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530003' to parameter: 4
00:35:07,216 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,216 DEBUG BatcherImpl:50 - Executing batch size: 2
00:35:07,226 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,226 DEBUG BatcherImpl:261 - closing statement
00:35:07,226 DEBUG BasicCollectionPersister:477 - Deleting collection: [demo.db.Mitarbeiter.projektSet#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,226 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,226 DEBUG SQL:237 - delete from MA_PRO where MA=?
Hibernate: delete from MA_PRO where MA=?
00:35:07,226 DEBUG BatcherImpl:241 - preparing statement
00:35:07,226 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 1
00:35:07,226 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,226 DEBUG BasicCollectionPersister:493 - done deleting collection
00:35:07,226 DEBUG BasicCollectionPersister:477 - Deleting collection: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,226 DEBUG BatcherImpl:50 - Executing batch size: 1
00:35:07,226 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,226 DEBUG BatcherImpl:261 - closing statement
00:35:07,226 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,226 DEBUG SQL:237 - delete from MA_PRO where PRO=?
Hibernate: delete from MA_PRO where PRO=?
00:35:07,226 DEBUG BatcherImpl:241 - preparing statement
00:35:07,236 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530002' to parameter: 1
00:35:07,236 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,236 DEBUG BasicCollectionPersister:493 - done deleting collection
00:35:07,236 DEBUG BasicCollectionPersister:477 - Deleting collection: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,236 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530003' to parameter: 1
00:35:07,236 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,236 DEBUG BasicCollectionPersister:493 - done deleting collection
00:35:07,236 DEBUG BatcherImpl:50 - Executing batch size: 2
00:35:07,236 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,236 DEBUG BatcherImpl:261 - closing statement
00:35:07,236 DEBUG BasicCollectionPersister:508 - Inserting collection: [demo.db.Mitarbeiter.projektSet#40288ca8fd76c5ac00fd76c5ae350001]
00:35:07,236 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,236 DEBUG SQL:237 - insert into MA_PRO (MA, PRO) values (?, ?)
Hibernate: insert into MA_PRO (MA, PRO) values (?, ?)
00:35:07,236 DEBUG BatcherImpl:241 - preparing statement
00:35:07,236 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 1
00:35:07,246 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530002' to parameter: 2
00:35:07,246 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,246 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 1
00:35:07,246 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530003' to parameter: 2
00:35:07,246 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,246 DEBUG BasicCollectionPersister:530 - done inserting collection: 2 rows inserted
00:35:07,246 DEBUG BasicCollectionPersister:508 - Inserting collection: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530002]
00:35:07,246 DEBUG BatcherImpl:50 - Executing batch size: 2
00:35:07,246 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,246 DEBUG BatcherImpl:261 - closing statement
00:35:07,246 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
00:35:07,246 DEBUG SQL:237 - insert into MA_PRO (PRO, MA) values (?, ?)
Hibernate: insert into MA_PRO (PRO, MA) values (?, ?)
00:35:07,246 DEBUG BatcherImpl:241 - preparing statement
00:35:07,246 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530002' to parameter: 1
00:35:07,246 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 2
00:35:07,246 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,256 DEBUG BasicCollectionPersister:530 - done inserting collection: 1 rows inserted
00:35:07,256 DEBUG BasicCollectionPersister:508 - Inserting collection: [demo.db.Projekt.mitarbeiterSet#40288ca8fd76c5ac00fd76c5ae530003]
00:35:07,256 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae530003' to parameter: 1
00:35:07,256 DEBUG StringType:46 - binding '40288ca8fd76c5ac00fd76c5ae350001' to parameter: 2
00:35:07,256 DEBUG BatcherImpl:28 - Adding to batch
00:35:07,256 DEBUG BasicCollectionPersister:530 - done inserting collection: 1 rows inserted
00:35:07,256 DEBUG BatcherImpl:50 - Executing batch size: 2
00:35:07,266 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.BatchUpdateException: Duplicate key or integrity constraint violation, message from server: "Duplicate entry '40288ca8fd76c5ac00fd76c5ae530003-40288ca8fd76c5ac00fd76c5ae350001' for key 1"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1461)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2417)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at demo.app.Receiver.main(Receiver.java:41)
00:35:07,276 WARN JDBCExceptionReporter:38 - SQL Error: 1062, SQLState: 23000
00:35:07,276 ERROR JDBCExceptionReporter:46 - Duplicate key or integrity constraint violation, message from server: "Duplicate entry '40288ca8fd76c5ac00fd76c5ae530003-40288ca8fd76c5ac00fd76c5ae350001' for key 1"
00:35:07,276 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
00:35:07,276 DEBUG BatcherImpl:261 - closing statement
00:35:07,276 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.BatchUpdateException: Duplicate key or integrity constraint violation, message from server: "Duplicate entry '40288ca8fd76c5ac00fd76c5ae530003-40288ca8fd76c5ac00fd76c5ae350001' for key 1"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1461)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2417)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at demo.app.Receiver.main(Receiver.java:41)
00:35:07,276 WARN JDBCExceptionReporter:38 - SQL Error: 1062, SQLState: 23000
00:35:07,276 ERROR JDBCExceptionReporter:46 - Duplicate key or integrity constraint violation, message from server: "Duplicate entry '40288ca8fd76c5ac00fd76c5ae530003-40288ca8fd76c5ac00fd76c5ae350001' for key 1"
00:35:07,307 ERROR JDBCExceptionReporter:38 - Could not execute JDBC batch update
java.sql.BatchUpdateException: Duplicate key or integrity constraint violation, message from server: "Duplicate entry '40288ca8fd76c5ac00fd76c5ae530003-40288ca8fd76c5ac00fd76c5ae350001' for key 1"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1461)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2417)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at demo.app.Receiver.main(Receiver.java:41)
The (non-hibernate stuff removed) code is:
Code:
// object deserialized from XML file, but problem is the same
// if the original fetched object is used without serialization/deserialization
// in between
Mitarbeiter m = (Mitarbeiter)new JSX.ObjectReader(new FileReader("dp.xml")).readObject();
Configuration cfg = new Configuration().configure(new File("hibernate-mysql.cfg.xml"));
SessionFactory sessions = cfg.buildSessionFactory();
Session session = sessions.openSession();
Transaction tx = session.beginTransaction();
session.replicate(m, ReplicationMode.OVERWRITE);
session.flush();
tx.commit();
session.close();