3

We are using JPA/Hibernate for project where we need to insert, say 10000 records in database with multiple joins/relations etc. The functionality is fine but the performance is really slow.

Just wondering if migrating to JDBC will help in some performance gain?

Thanks,
-csn

1

1 Answer 1

5

You can do batch inserts with JPA/Hibernate - see "Batch processing".

You would almost certainly get better performance by doing batch inserts in JDBC (addBatch(), etc), but the Hibernate method may be more desirable if your schema is complex.

If you use JDBC batches, make sure that you do all of your addBatch() calls in a transaction.

If you happen to be using MySQL, be sure to add rewriteBatchedStatements=true to your connection parameters.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.