Versions:
Hibernate 3.0.5, jTDS 1.0.3, c3p0 0.9.0-pre6
Mapping documents:
<property name="hibernate.jdbc.batch_size">10</property>
<property name="hibernate.jdbc.batch_versioned_data">true</property>
Name and version of the database you are using:
SQL Server 2000 SP3
Debug level Hibernate log excerpt:
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
Hibernate: insert into ITEM (...) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
Hibernate: insert into ITEM_TEST (TEST_ID, TEST_REQUIRED_FLAG, TEST_STATE_ID, ITEM_ID) values (?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
Hibernate: insert into ITEM_TEST (TEST_ID, TEST_REQUIRED_FLAG, TEST_STATE_ID, ITEM_ID) values (?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
Hibernate: insert into ITEM_TEST (TEST_ID, TEST_REQUIRED_FLAG, TEST_STATE_ID, ITEM_ID) values (?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
As you can see, my batch inserts are not batching. I've been through the Hibernate, jTDS and c3p0 docs and I can't see anything that would prevent this from working. The parent entity (ITEM) is versioned, but as you can see, batch versioned updates are enabled, and it's not the one that should be batched anyway. The association (to ITEM_TEST, the child entity) is mapped using @OneToMany(..., cascade=CascadeType.ALL). There is actually more than one such association leading away from ITEM; this is just one of them. I tried disabling cascades on all but one but it didn't help.
Can inserts resulting from cascades be batched? If so, what am I doing wrong?
|