Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The JPA API doesn't provide you all the options to make this optimal. Depending on how fast you want to do this you are going to have to look for ORM specific options - Hibernate in your case.</p> <p>Things to check:</p> <ol> <li>Check you are using a single transaction (Yes, apparently you are sure of this)</li> <li>Check your JPA provider (Hibernate) is using the JDBC batch API (refer: hibernate.jdbc.batch_size)</li> <li>Check if you can bypass getting generated keys (depends on db/jdbc driver how much benefit you get from this - refer: hibernate.jdbc.use_getGeneratedKeys)</li> <li>Check if you can bypass cascade logic (only minimal performance benefit from this)</li> </ol> <p>So in Ebean ORM this would be:</p> <pre><code> EbeanServer server = Ebean.getServer(null); Transaction transaction = server.beginTransaction(); try { // Use JDBC batch API with a batch size of 100 transaction.setBatchSize(100); // Don't bother getting generated keys transaction.setBatchGetGeneratedKeys(false); // Skip cascading persist transaction.setPersistCascade(false); // persist your beans ... Iterator&lt;YourEntity&gt; it = null; // obviously should not be null while (it.hasNext()) { YourEntity yourEntity = it.next(); server.save(yourEntity); } transaction.commit(); } finally { transaction.end(); } </code></pre> <p>Oh, and if you do this via raw JDBC you skip the ORM overhead (less object creation / garbage collection etc) - so I wouldn't ignore that option.</p> <p>So yes, this doesn't answer your question but might help your search for more ORM specific batch insert tweaks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload