I'd like to configure hibernate batch_size
.
I configured it in my hibernate configuration as follows:
configuration.setProperty("hibernate.jdbc.batch_versioned_data",
"true");
configuration.setProperty("hibernate.jdbc.batch_size", "100");
configuration.setProperty("hibernate.jdbc.fetch_size", "400");
configuration.setProperty("hibernate.order_inserts", "true");
configuration.setProperty("hibernate.update_inserts", "true");
I created a test table in my db called TEST with just one integer field. The related entity is:
@Entity
@Table(name = "Test")
public class TestEntity implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "Field")
private int field;
}
I wrote a very sample test method to create some data:
tx = session.beginTransaction();
for (int i = 0; i < 1000; i++) {
TestEntity test = new TestEntity(i);
session.save(test);
}
tx.commit();
But in hibernate output the insert are performed one by one:
Hibernate:
insert
into
Test
(Field)
values
(?)
Hibernate:
insert
into
Test
(Field)
values
(?)
Hibernate:
insert
into
Test
(Field)
values
(?)
Hibernate:
insert
into
Test
(Field)
values
(?)
Hibernate:
insert
into
Test
(Field)
values
(?)
Hibernate:
insert
into
Test
(Field)
values
(?)
.......
.......
I'm not really understanding why it isn't working.
Any ideas?