title: EclipseLink/JPA @OneToMany Backpointer Cardinality Error
body: <p>I am trying to generate a unidirectional one-to-many mapping between two JPA entities. In my <code>ChatRoom</code> class, I have a <code>Vector&lt;User&gt;</code> type object that represents <code>User</code>s in a <code>ChatRoom</code>. I am trying to create a one-to-many mapping, based on <code>userId</code> (in the <code>User</code> class). Here is my sample code:</p>
  
  <pre><code>@Entity
  public class ChatRoom {
      @Id
      @GeneratedValue
      private int chatRoomID;
  
      @OneToMany(mappedBy="userID")
      private Vector&lt;User&gt; users;
  
      // A no-argument constructor is required for EclipseLink to instantiate the persistence object properly.
      public ChatRoom() {}
  
      // Getter/Setter section
  }
  </code></pre>
  
  <p>Here is the User class:</p>
  
  <pre><code>@Entity
  public class User {
      @Id
      @GeneratedValue
      private int userID;
  
      private String username;
  
      // Getter/Setter section
  }
  </code></pre>
  
  <p>When I try to generate the tables from these entities in Eclipse, I get the following error:</p>
  
  <pre><code>Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.EntityManagerSetupException
  Exception Description: Predeployment of PersistenceUnit [ChatJPA] failed.
  Internal Exception: Exception [EclipseLink-7244] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
  Exception Description: An incompatible mapping has been encountered between [class iosoa.entity.ChatRoom] and [class iosoa.entity.User]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.
      at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
  </code></pre>
  
  <p>Do you have any ideas on how to resolve this problem? Thanks for your help.</p>