In your PK object, you do not need to store identifiers as long (in fact, this is true every time you need a reference to the object). When compared with the actual database schema, the JPA replaces all references to other objects with object identifiers.
, ( , "" ):
@Embeddable
public class NpcTradeGoodPK implements Serializable {
@ManyToOne
@JoinColumn(name = "npc_id", nullable = false)
private Npc npc;
@ManyToOne
@JoinColumn(name = "good_id", nullable = false)
private Good good;
@Column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
private ItemType type;
}
... JPA , : "long npc_id", "Npc npc"; "long good_id", "".
: @Column @ManyToOne. @JoinColumn, , .
, "". "nullable" .
: ah, Npc NpcTradeGoodPK, , Npc , . .