Hello vlad,
Quote:
So, how does it use a separate mapping table then?
I don't understand this question, because it is a bidirectional mapping, the @JoinTable-annotation is on the many-side.
Quote:
You should add the logged SQL statements as well.
Here is the log-file for inserting the entries on the one-side in table A with using batch:
Code:
2017-04-27 09:03:33,451 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-0]
2017-04-27 09:03:33,469 TRACE [org.hibernate.service.internal.AbstractServiceRegistryImpl] (default task-1) Initializing service [role=org.hibernate.engine.jdbc.batch.spi.BatchBuilder]
2017-04-27 09:03:33,471 TRACE [org.hibernate.service.internal.AbstractServiceRegistryImpl] (default task-1) Initializing service [role=org.hibernate.jmx.spi.JmxService]
2017-04-27 09:03:33,472 TRACE [org.hibernate.engine.jdbc.batch.internal.BatchBuilderImpl] (default task-1) Building batch [size=10]
2017-04-27 09:03:33,478 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,547 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Registering statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@4f1b4848]
2017-04-27 09:03:33,548 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-0]
2017-04-27 09:03:33,551 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-0]
2017-04-27 09:03:33,551 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-0]
2017-04-27 09:03:33,552 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-1]
2017-04-27 09:03:33,552 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,552 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,552 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-1]
2017-04-27 09:03:33,552 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-1]
2017-04-27 09:03:33,552 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-1]
2017-04-27 09:03:33,552 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-2]
2017-04-27 09:03:33,552 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,552 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,552 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-2]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-2]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-2]
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-3]
2017-04-27 09:03:33,553 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,553 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-3]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-3]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-3]
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-4]
2017-04-27 09:03:33,553 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,553 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-4]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-4]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-4]
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-5]
2017-04-27 09:03:33,553 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,553 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-5]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-5]
2017-04-27 09:03:33,553 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-5]
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-6]
2017-04-27 09:03:33,553 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,553 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,553 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-6]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-6]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-6]
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-7]
2017-04-27 09:03:33,554 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,554 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-7]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-7]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-7]
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-8]
2017-04-27 09:03:33,554 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,554 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-8]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-8]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-8]
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-9]
2017-04-27 09:03:33,554 DEBUG [org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] (default task-1) Reusing batch statement
2017-04-27 09:03:33,554 DEBUG [org.hibernate.SQL] (default task-1) insert into A (NAME, ID) values (?, ?)
2017-04-27 09:03:33,554 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.A#ID-A-9]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-9]
2017-04-27 09:03:33,554 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-A-9]
2017-04-27 09:03:33,555 DEBUG [org.hibernate.engine.jdbc.batch.internal.BatchingBatch] (default task-1) Executing batch size: 10
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 0
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 1
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 2
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 3
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 4
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 5
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 6
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 7
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 8
2017-04-27 09:03:33,561 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 9
and here is the log-file-part for inserting the many-side entries in table B and in the mapping-table A2B without using batch:
Code:
2017-04-27 09:03:41,783 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.B#ID-B-29ID-A-28]
2017-04-27 09:03:41,783 DEBUG [org.hibernate.SQL] (default task-1) insert into B (NAME, ID) values (?, ?)
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Registering statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@278944be]
2017-04-27 09:03:41,783 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.B#ID-B-29ID-A-28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [Name ID-29 Parent 28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-B-29ID-A-28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Inserting entity: [com.atron.atries.rx.asdm.dao.entity.netex.B#ID-B-29ID-A-28]
2017-04-27 09:03:41,783 DEBUG [org.hibernate.engine.jdbc.batch.internal.BatchingBatch] (default task-1) Executing batch size: 1
2017-04-27 09:03:41,783 DEBUG [org.hibernate.jdbc.Expectations] (default task-1) Success of batch update unknown: 0
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Releasing statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@278944be]
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Closing prepared statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@278944be]
2017-04-27 09:03:41,783 TRACE [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl] (default task-1) Starting after statement execution processing [AFTER_STATEMENT]
2017-04-27 09:03:41,783 DEBUG [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl] (default task-1) Skipping aggressive release due to manual disabling
2017-04-27 09:03:41,783 DEBUG [org.hibernate.SQL] (default task-1) insert into A2B (A_ID, B_ID) values (?, ?)
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Registering statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@1ca56b4c]
2017-04-27 09:03:41,783 TRACE [org.hibernate.persister.entity.AbstractEntityPersister] (default task-1) Dehydrating entity: [com.atron.atries.rx.asdm.dao.entity.netex.B#ID-B-29ID-A-28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [1] as [VARCHAR] - [ID-A-28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (default task-1) binding parameter [2] as [VARCHAR] - [ID-B-29ID-A-28]
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Releasing statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@1ca56b4c]
2017-04-27 09:03:41,783 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Closing prepared statement [org.jboss.jca.adapters.jdbc.jdk7.WrappedPreparedStatementJDK7@1ca56b4c]
2017-04-27 09:03:41,783 TRACE [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl] (default task-1) Starting after statement execution processing [AFTER_STATEMENT]
The entity in table B is inserted with
batch size 1 and immediatly after that the mapping entry is inserted.