title: Strange behaviour while trying to add element to a JPA entity list : only the first element persist
body: <p>sorry for my English in advance.
  I trying to add elements in an entity list and <strong>only the first element stay in this list</strong>.</p>
  
  <p>Here an example :</p>
  
  <pre><code>Project project = project_facade.find(1L);
  Machine machine = machine_facade.find(1L);
  
  for(int i=0;i&lt;3;i++){
      Test test = new Test();
      test.setName("Test "+i);
  
      test.setProject(project);
      test.setMachine(machine);
  
      project.getTestList().add(test);
      machine.getTestList().add(test);
  }
  
  project.getMachineList().add(machine);
  machine.getProjectList().add(project);
  
  project_facade.edit(project);
  </code></pre>
  
  <p>After this, in the database, the project and the machine are linked correctly (through a mapping table), but the Test table contains only the record "Test 0" (the project_id field and machine_id field are correct).</p>
  
  <p>I don't understand why it's work for the first element only...</p>
  
  <p>Thanks for your help !!!</p>
  
  <p>Project entity:</p>
  
  <pre><code>@Entity
  public class Project implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "id")
      private Long id;
  
      @Basic(optional = false)
      @NotNull
      @Size(min = 1, max = 45)
      @Column(name = "name")
      private String name;
  
      @ManyToMany(mappedBy = "projectList", cascade = CascadeType.ALL)
      private List&lt;Machine&gt; machineList;
  
      @OneToMany(mappedBy = "project", cascade = CascadeType.ALL *SOLUTION : ,fetch = FetchType.EAGER* )
      private List&lt;Test&gt; testList;
  
      //constructor, getters, setters
  }
  </code></pre>
  
  <p>Machine Entity:</p>
  
  <pre><code>@Entity
  public class Machine implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "id")
      private Long id;
  
      @Basic(optional = false)
      @NotNull
      @Size(min = 1, max = 45)
      @Column(name = "name")
      private String name;
  
      @JoinTable(name = "project_machine", joinColumns = {
          @JoinColumn(name = "machine", referencedColumnName = "id")}, inverseJoinColumns = {
          @JoinColumn(name = "project", referencedColumnName = "id")})
      @ManyToMany
      private List&lt;Project&gt; projectList;
  
      @OneToMany(mappedBy = "machine",cascade = CascadeType.ALL)
      private List&lt;Test&gt; testList;
  
      //constructor, getters, setters
  }
  </code></pre>
  
  <p>Test Entity:</p>
  
  <pre><code>@Entity
  public class Test implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "id")
      private Long id;
  
      @Basic(optional = false)
      @NotNull
      @Size(min = 1, max = 64)
      @Column(name = "name")
      private String name;
  
      @JoinColumn(name = "project", referencedColumnName = "id")
      @ManyToOne(optional = false)
      private Project project;
  
      @JoinColumn(name = "machine", referencedColumnName = "id")
      @ManyToOne(optional = false)
      private Machine machine;
  
      //constructor, getters, setters
  }
  </code></pre>
  
  <p>Then all my facades extends AbstractFacade where edit method is:</p>
  
  <pre><code>public void edit(T entity) {
          getEntityManager().merge(entity);
      }
  </code></pre>