1 Reply Latest reply on Feb 12, 2006 9:41 AM by Emmanuel Bernard

    Foreign keys in composite PKs

    Jeff Schnitzer Newbie

      Can I use an entity reference as part of a composite primary key, like this?

      @Embeddable
      public class FavoritePK implements java.io.Serializable
      {
       /** */
       @ManyToOne
       @JoinColumn(name="ownerId")
       Person owner;
      
       @ManyToOne
       @JoinColumn(name="targetId")
       Person target;
      
       /** */
       public FavoritePK() {}
      
       /** */
       public FavoritePK(Person owner, Person target)
       {
       this.owner = owner;
       this.target = target;
       }
      
       ...
      


      The docs don't seem to indicate one way or another and I'd like to know before I tear apart my data model.

      Thanks in advance!