title: JPA join table with more than one entity
body: <p>I have an Entity that looks like this:</p>
  
  <pre><code>public class NpcTradeGood implements Serializable, Negotiabble {
      private static final long serialVersionUID = 1L;
      @EmbeddedId
      protected NpcTradeGoodPK npcTradeGoodPK;
      @JoinColumn(name = "npc_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
      @ManyToOne(optional = false)
      private Npc npc;
  }
  
  @Embeddable
  public class NpcTradeGoodPK implements Serializable {
      @Basic(optional = false)
      @Column(name = "npc_id", nullable = false)
      private long npcId;
      @Basic(optional = false)
      @Column(name = "good_id", nullable = false)
      private long goodId;
      @Basic(optional = false)
      @Column(name = "type", nullable = false)
      @Enumerated(EnumType.STRING)
      private ItemType type;
  }
  </code></pre>
  
  <p>Is there a way to tell JPA which OneToMany relationship it is based on the type column (enumeration)?
  Like if its a part or any other entity it automatically gets the related entity.</p>
  
  <p>Thanks in advance.</p>