JPA batch inserts (using Hibernate and Spring Data JPA)

JPA tagImplementing JPA batch inserts aka bulk inserts with Hibernate and Spring Data JPA I learned a few things:

Related Posts

7 thoughts on “JPA batch inserts (using Hibernate and Spring Data JPA)

  1. Hi,

    I was going through this post, but unable to get anything, you just put the things/questions together, but where is the solution ?

    Please reply.

    Thanks,
    Adeel

  2. Ok, the post is calling “JPA batch inserts (using Hibernate and Spring Data JPA)”
    but i cannot see the manual how to do it using Hibernate and Spring Data;
    I only see the part that explains the hibernate configuration for it;

    Can you please give an explanation or manual how to make JPA batch inserts (using Hibernate and Spring Data JPA) ?

    Thank you.
    PS
    I agree with Adeel Ahmad and I understand what did he ask about. As far as I understand = that same question as I am.

    1. Hhhm, ok…thanks for your feedback. You need to read the articles I linked to in order to understand what problem is. Would you rather want me to repeat the solutions documented in the other articles?

  3. Hi,

    Thanks for your interesting links.

    I understand that from time to time, it’s necessary to empty the first level cache and send everything to the database:


    session.flush();
    session.clear();

    However since Spring Data JPA Repositories are used here, there is only a flush() method from JpaRepository exposed. Does the call to this method is strictly equivalent to the above two calls ?

    JpaRepository does not expose a clear() method. SimpleJpaRepository never ever call the clear() method of its internal JPA EntityManager.

    Check source code: https://github.com/spring-projects/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java

    Are you aware of these implementation details ? If so, how did you do to be sure that the flush() and clear() of the underlying Hibernate session are effectivly called ?

Leave a Reply

Your email address will not be published. Required fields are marked *