0

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 ?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Badman
  • 407
  • 5
  • 17

0 Answers0