hibernate reference doc recommends the following code for batch inserts:
Code:
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();
}
}
the Problem is that i do not want to clear the whole session cache, i only want to eliminate the batch-inserted objects.
Instead of calling session.clear(), i'd like to havel something like
Code:
session.clear(Customer.class)
or
session.evict(Customer.class)
i haven't found any of those methods or something equivalent in Hib3rc2 ... any chance for such a method in a future release?
or is there any way to clear all InstancesOf without calling session.evict(Object) for every object?