9 Replies Latest reply on Mar 25, 2006 10:39 AM by epbernard

    @PrimaryKeyJoinColumns  is disallowed annotation

    adver11

      In EJB3.0 RC5:

      @Entity
      public class Customer implements Serializable {
       @EmbeddedId
       CustomerPK customerpk;
       ..............
      
       @ManyToOne
       @PrimaryKeyJoinColumns({
       @PrimaryKeyJoinColumn(name = "CUSTOMERID", referencedColumnName = "ID"),
       @PrimaryKeyJoinColumn(name = "NAME", referencedColumnName = "NAME")
       })
       private Airline airline;
      
       .............
      }


      but the IDE shows me :The annotation @PrimaryKeyJoinColumns is disallowed for this location

      In ejb-3_0-pfd-spec-persistence:
      Composite foreign keys are supported by means of the PrimaryKeyJoinColumns annotation. The
      PrimaryKeyJoinColumns annotation groups PrimaryKeyJoinColumn annotations.
      Example 2: OneToOne relationship between Employee and EmployeeInfo classes
      public class EmpPK {
       public Integer id;
       public String name;
      }
      
      @Entity
      @IdClass(com.acme.EmpPK.class)
      public class Employee {
       @Id Integer id;
       @Id String name;
       @OneToOne
       @PrimaryKeyJoinColumns({
       @PrimaryKeyJoinColumn(name="ID", referencedColumnName="EMP_ID"),
       @PrimaryKeyJoinColumn(name="NAME", referencedColumnName="EMP_NAME")})
       EmployeeInfo info;
       ...
      }
      
      @Entity
      @IdClass(com.acme.EmpPK.class)
      public class EmployeeInfo {
       @Id @Column(name="EMP_ID")
       Integer id;
       @Id @Column(name="EMP_NAME")
       String name;
       ...
      }


      Why disallowed?