I found and interesting article about loading and reading data with JPA. There are performance issues when you want to insert 1’000 or 10’000 records in the database.

Before ORM life was complicated … 25 lines of code to insert a line in the database, not it’s easier: entityManager.persist(object)!

The frameworks (Hibernate, Toplink …) do all the work and they do very well the work. The problem with JPA is that we cannot flush the session like in hibernate and send 50 or 100 records in a block to the DB. JPA send and retrieve each object in a transaction. Inserting 10’000 records takes minutes … 1’000’000 hours.

The solution is to use direcly JDBC, ETL product or frameworks (Spring Batch, …).

JPA is something great but it cannot manage everything 🙁 no party for the lazy developers … yet!