I have two classes, Cell and Character. Basically, the cell is like a room, and contains a variable (private Set<Long> cellHeldCharacters;) which holds the IDs of the characters within the cell (The IDs are Primary Keys). Can I use the Foreign Key annotation for the variable, or is it illegal/unrecommended to do it for a Set?
For a better picture, I have:
@Entity public class Character { @Id @GeneratedValue private long characterId; private String characterName; private Location characterLocation;
and:
@Entity public class Cell { @Id @GeneratedValue private long cellID; private String cellName; private String cellShortDesc; private String cellLongDesc; private String cellBlockDesc; private Location cellLocation; private double cellSize; private Set<Long> cellHeldCharacters;
And I want to know if I can do this safely and retrieve it nicely later on:
@Entity public class Cell { @Id @GeneratedValue private long cellID; private String cellName; private String cellShortDesc; private String cellLongDesc; private String cellBlockDesc; private Location cellLocation; private double cellSize; @ForeignKey private Set<Long> cellHeldCharacters;