mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 12:44:49 +00:00
HHH-12419 - Incorrect batch inserts example
This commit is contained in:
parent
a8a9bde70b
commit
c22540ab65
@ -200,15 +200,15 @@ private void withBatch() {
|
|||||||
|
|
||||||
int batchSize = 25;
|
int batchSize = 25;
|
||||||
|
|
||||||
for ( int i = 0; i < entityCount; ++i ) {
|
for ( int i = 0; i < entityCount; i++ ) {
|
||||||
Person Person = new Person( String.format( "Person %d", i ) );
|
|
||||||
entityManager.persist( Person );
|
|
||||||
|
|
||||||
if ( i > 0 && i % batchSize == 0 ) {
|
if ( i > 0 && i % batchSize == 0 ) {
|
||||||
//flush a batch of inserts and release memory
|
//flush a batch of inserts and release memory
|
||||||
entityManager.flush();
|
entityManager.flush();
|
||||||
entityManager.clear();
|
entityManager.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Person Person = new Person( String.format( "Person %d", i ) );
|
||||||
|
entityManager.persist( Person );
|
||||||
}
|
}
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user