Hi, I have an Entity that looks like this:
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;
}
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.
Thanks in advance.