title: JPA an Java - @JoinColumns error
body: <p>I am currently trying to display information requested via JPA 2.0 (eclipselink). I am using glassfish 3.0.1 and netbeans 6.9.1 as IDE. My persistence entities are created under netbeans option "create entity classes from database". My shcema is designed with workbench mysql, and my server is of course mysql. I really cant figure out what creates this @JoinColumns error. </p>
  
  <pre><code>javax.servlet.ServletException: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
  Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
  Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.EntityManagerSetupException
  Exception Description: Predeployment of PersistenceUnit [myprojectPU] failed.
  Internal Exception: Exception [EclipseLink-7220] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.ValidationException
  Exception Description: The @JoinColumns on the annotated element [field userInfo] from the entity class [class com.myproject.jpa.UserId] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referencedColumnName elements must be specified in each such @JoinColumn.
  </code></pre>
  
  <p>This part randomly swaps from <strong>[field userInfo] from the entity class [class com.myproject.jpa.UserId]</strong> to <strong>[field userIdList] from the entity class [class com.myproject.jpa.Cell].</strong> So both classes probably have the same issue. </p>
  
  <p>Here are my classes:</p>
  
  <pre><code>@Entity
  @XmlRootElement
  @Table(name = "user_id", catalog = "workitout", schema = "")
  public class UserId implements Serializable {
      private static final long serialVersionUID = 1L;
      @EmbeddedId
      protected UserIdPK userIdPK;
      @Basic(optional = false)
      @Column(name = "email", nullable = false, length = 45)
      private String email;
      @Basic(optional = false)
      @Column(name = "password", nullable = false, length = 45)
      private String password;
  
      @ManyToMany(mappedBy = "userIdList")
      private List&lt;Cell&gt; cellList;
  
      @JoinColumn(name = "USER_INFO_id_info", referencedColumnName = "id_info", nullable = false, insertable = false, updatable = false)
      @ManyToOne(optional = false)
      private UserInfo userInfo;
  
      ...    
  }
  
  @Entity
  @XmlRootElement
  @Table(name = "user_info", catalog = "workitout", schema = "")
  public class UserInfo implements Serializable {
      private static final long serialVersionUID = 1L;
      @EmbeddedId
      protected UserInfoPK userInfoPK;
      @Basic(optional = false)
      @Column(name = "fullName", nullable = false, length = 45)
      private String fullName;
      @Basic(optional = false)
      @Column(name = "city", nullable = false, length = 45)
      private String city;
      @Basic(optional = false)
      @Column(name = "gender", nullable = false, length = 10)
      private String gender;
      @Basic(optional = false)
      @Column(name = "isCoach", nullable = false)
      private boolean isCoach;
      @Column(name = "age")
      private Integer age;
      @Column(name = "description", length = 200)
      private String description;
      @Column(name = "linkImage", length = 45)
      private String linkImage;
      @Column(name = "friendList", length = 500)
      private String friendList;
      @Column(name = "coachList", length = 500)
      private String coachList;
  
      @JoinColumn(name = "USER_SPORT_id_sport", referencedColumnName = "id_sport", nullable = false, insertable = false, updatable = false)
      @ManyToOne(optional = false)
      private UserSport userSport;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "userInfo")
      private List&lt;UserId&gt; userIdList;
  
      ...  
  }
  </code></pre>
  
  <p>*The first error was solved, but the <strong>[field userIdList] from the entity class [class com.myproject.jpa.Cell].</strong> remains. Ive added the code of my cell table:</p>
  
  <pre><code>import java.io.Serializable;
  import java.util.List;
  import javax.persistence.Basic;
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.NamedQueries;
  import javax.persistence.NamedQuery;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlTransient;
  
  @Entity
  @XmlRootElement
  @Table(name = "cell", catalog = "workitout", schema = "")
  @NamedQueries({
      @NamedQuery(name = "Cell.findAll", query = "SELECT c FROM Cell c"),
      @NamedQuery(name = "Cell.findByIdCell", query = "SELECT c FROM Cell c WHERE c.idCell = :idCell"),
      @NamedQuery(name = "Cell.findByName", query = "SELECT c FROM Cell c WHERE c.name = :name")})
  public class Cell implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Basic(optional = false)
      @Column(name = "id_cell", nullable = false)
      private Integer idCell;
      @Basic(optional = false)
      @Column(name = "name", nullable = false, length = 45)
      private String name;
  
      @ManyToMany
      @JoinTable(name = "user_id_has_cell", joinColumns = {
          @JoinColumn(name = "cell_id_cell", referencedColumnName = "id_cell", nullable = false)}, inverseJoinColumns = {
          @JoinColumn(name = "USER_ID_id", referencedColumnName = "id", nullable = false),
          @JoinColumn(name = "USER_INFO_id_info", referencedColumnName = "id_info", nullable = false, insertable = false, updatable = false),
          @JoinColumn(name = "USER_SPORT_id_sport", referencedColumnName = "id_sport", nullable = false, insertable = false, updatable = false)
      })
      private List&lt;UserId&gt; userIdList;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "cell")
      private List&lt;WorkoutSession&gt; workoutSessionList;
  
      public Cell() {
      }
  
      public Cell(Integer idCell) {
          this.idCell = idCell;
      }
  
      public Cell(Integer idCell, String name) {
          this.idCell = idCell;
          this.name = name;
      }
  
      public Integer getIdCell() {
          return idCell;
      }
  
      public void setIdCell(Integer idCell) {
          this.idCell = idCell;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public List&lt;UserId&gt; getUserIdList() {
          return userIdList;
      }
  
      public void setUserIdList(List&lt;UserId&gt; userIdList) {
          this.userIdList = userIdList;
      }
  
      public List&lt;WorkoutSession&gt; getWorkoutSessionList() {
          return workoutSessionList;
      }
  
      public void setWorkoutSessionList(List&lt;WorkoutSession&gt; workoutSessionList) {
          this.workoutSessionList = workoutSessionList;
      }
  
      @Override
      public int hashCode() {
          int hash = 0;
          hash += (idCell != null ? idCell.hashCode() : 0);
          return hash;
      }
  
      @Override
      public boolean equals(Object object) {
          // TODO: Warning - this method won't work in the case the id fields are not set
          if (!(object instanceof Cell)) {
              return false;
          }
          Cell other = (Cell) object;
          if ((this.idCell == null &amp;&amp; other.idCell != null) || (this.idCell != null &amp;&amp; !this.idCell.equals(other.idCell))) {
              return false;
          }
          return true;
      }
  </code></pre>