Created
August 20, 2018 22:06
-
-
Save jerolba/30c63eafec74bc9b4f77a5d78d61262a to your computer and use it in GitHub Desktop.
A register each time in transactions of 1000 elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EntityTransaction tx = entityManager.getTransaction(); | |
Iterator<TripEntity> iterator = trips.iterator(); | |
tx.begin(); | |
int cont = 0; | |
while (iterator.hasNext()) { | |
entityManager.persist(iterator.next()); | |
cont++; | |
if (cont % batchSize == 0) { | |
tx.commit(); | |
tx.begin(); | |
} | |
} | |
tx.commit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment