tx.begin();
for (int i = 0; i < NUMBER_TO_INSERT; ++i) {
// must be done with an active transaction
Employee2 e = session.find(Employee2.class, i);
// see if it is the right Employee
int actualId = e.getId();
if (actualId != i) {
error("Expected Employee2.id " + i + " but got " + actualId);
}
}
tx.commit();