HHH-12419 - Incorrect batch inserts example

This commit is contained in:
Vlad Mihalcea 2018-03-22 14:22:51 +02:00
parent a8a9bde70b
commit c22540ab65
1 changed files with 4 additions and 4 deletions

View File

@ -200,15 +200,15 @@ public class BatchTest extends BaseEntityManagerFunctionalTestCase {
int batchSize = 25;
for ( int i = 0; i < entityCount; ++i ) {
Person Person = new Person( String.format( "Person %d", i ) );
entityManager.persist( Person );
for ( int i = 0; i < entityCount; i++ ) {
if ( i > 0 && i % batchSize == 0 ) {
//flush a batch of inserts and release memory
entityManager.flush();
entityManager.clear();
}
Person Person = new Person( String.format( "Person %d", i ) );
entityManager.persist( Person );
}
txn.commit();