Skip to content

Commit 1e46a9f

Browse files
Update Dao.java
1 parent 6ee5218 commit 1e46a9f

File tree

1 file changed

+6
-1
lines changed
  • HibernateSpringBootBatchInsertsViaSession/src/main/java/com/jpa

1 file changed

+6
-1
lines changed

HibernateSpringBootBatchInsertsViaSession/src/main/java/com/jpa/Dao.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ public <S extends T> Iterable<S> saveInBatch(Iterable<S> entities) {
5858
i = 0;
5959
}
6060
}
61+
62+
if (i > 0) {
63+
entityManager.flush();
64+
entityManager.clear();
65+
}
6166

6267
return result;
6368
}
6469

6570
protected EntityManager getEntityManager() {
6671
return entityManager;
6772
}
68-
}
73+
}

0 commit comments

Comments
 (0)