openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Luis Cetina <>
Subject ManyToMany tries to insert twice
Date Wed, 24 Sep 2014 20:44:51 GMT
Hi, im not sure if i have a clear concept about the Many to Many persist.

I have this scenario.

table: courses

table: documents

table: courses_documents

Then my entities:

public class Course{

   private int courseId;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "courses_documents",
            inverseJoinColumns =
    private Set<Document> documents;


public class Document{

   private int documentId;

   private Set<Course> courses;

Then  when i want to persist i did this.

  Course course = em.merge(aCourse);

  //i get a reference of an existed document
  Document doc1 = entityManager.getReference(...);

  //then i add that document to course

then jpa tries to insert twice in courses_documents  why twice??


*José Luis Cetina*

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message