I would like to know this also.
we need to insert data into several tables very fast, and I'm wondering if using StatelessSession is the best we can get with Hibernate.
unfortunately, the documentation does not comment on this - what is the best way to perform mass insert.
The example provided in section 13.1 of the documentation:
Quote:
13.1. Batch inserts
for ( int i=0; i<100000; i++ ) {
Customer customer = new Customer(.....);
session.save(customer);
if ( i % 20 == 0 ) { //20, same as the JDBC batch size
//flush a batch of inserts and release memory:
session.flush();
session.clear();
}
}
does not work when need to create a group of records, which should be LINKED to other tables (typical "
failed to lazily initialize a collection of role" error happens, if flushing and clearing the session in the middle of process). I already complained about this on the forum.