Can I use more than one @Id annotation in an Entity?
I want to define a table where the entire record is the primary key. The
table has two columns which are references to other entities.
@Entity
public class ProtoList implements Serializable {
@Id
@ManyToOne ProtoObject listID;
@Id
@OneToOne ProtoObject po;
ProtoObject is an entity whose @Id is a regular generated Long.
The resulting relational data structure is intended allow any ProtoObject
to be associated with an arbitrarily long List (actually a Set) of
ProtoObjects. So the two table columns are just two Longs, always unique.
Will this work or do I have to define an @IdClass or something else?
No comments:
Post a Comment