When merge is cascaded to a new entity object that has not been persisted yet - it becomes persisted twice rather than once.
This was demonstrated by a Java EE application in this forum thread but may be reproduced also in a simple console test case:
import java.util.*; import javax.persistence.*; @Entity public class T595 { public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory( "objectdb:$objectdb/db/test.tmp;drop"); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); em.persist(new Book()); em.getTransaction().commit(); em.close(); em = emf.createEntityManager(); Book book = em.find(Book.class, 1); em.close(); em = emf.createEntityManager(); em.getTransaction().begin(); book.chapters = Arrays.asList(new Chapter()); em.merge(book); em.getTransaction().commit(); em.close(); em = emf.createEntityManager(); Query query = em.createQuery("SELECT COUNT(c) FROM Chapter c"); System.out.println(query.getSingleResult()); em.close(); emf.close(); } @Entity public static class Book { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(cascade= CascadeType.ALL, fetch= FetchType.EAGER) private List<Chapter> chapters; } @Entity public static class Chapter { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; } }