Batch size not working with Google Guice + JPA + Hibernate

111 views Asked by At

I am using Google Guice as dependency injection and Transaction purpose along with JPA and Hibernate.

I have added <property name="hibernate.jdbc.batch_size" value="20" /> in my persistence.xml file.

Here is my save entity list DAO code :

@Transactional
public void save(final List<T> entities) {
    final EntityManager em = getEntityManager();
    for (final T entity : entities) {
        if (!em.contains(entity)) {
            em.persist(entity);
        }
    }
}

Why it is not inserting in Database in batch of size 20 ?

0

There are 0 answers