Technology stack: Oracle database 11.2.0.2, Java 1.6, Hibernate 3.6.6.Final.
I am new to hibernate, apologize if this is trivial.
The following code was supposed to put some optimization:
Transaction tx = session.beginTransaction();
for (int i = 0; i < 10; i++) {
POJO pojo = new POJO(i);
session.save(pojo);
}
tx.commit();
hibernate.cfg.xml
has the following entry
<property name="jdbc.batch_size">500</property>
How can I verify, if hibernate really batches all these inserts? If it performs 10 inserts than there is no gain.
One idea is to put the jdbc plain query right after save()
that checks if the record was added to db:
String query = "retrieve previously added element"
PreparedStatement stmt = session.connection().prepareStatement(query.toString());
Result rs = statement.executeQuery();
/** check contents of rs */
In my case it returns a non empty set with previously added element. Does it mean anything? How else can I check if batching works.
thanks in advance