This content has been marked as final.
Show 3 replies
-
1. Re: mappedBy to a PK property
bill.burke Jan 30, 2006 1:52 PM (in response to cesarizurieta)what you are trying to do is not legal in the specification. Only basic types are allowed within Embeddables
-
2. Re: mappedBy to a PK property
cesarizurieta Jan 30, 2006 3:09 PM (in response to cesarizurieta)What if I use @IdClass like this (removing the @ManyToOne from the PK class):
@Entity @IdClass(OnePK.class) public class One { private int a; private Two two; @Id public A getA() { return a; } public setA(A) { this.a = a; } @Id @ManyToOne public Two getTwo() { return two; } public setTwo(Two two) { this.two = two; } }
It doesn't work either. Is there any other way I can map a collection to a composite PK field? -
3. Re: mappedBy to a PK property
bill.burke Jan 30, 2006 3:35 PM (in response to cesarizurieta)I don't remember if @PrimaryKeyJoinColumn exists in RC3, but you can try this out on the RC4 release that we are putting out today.
@Entity public class One { private OnePK one; private Two two; @EmbeddedId public OnePk getPK() { return a; } public setPK(OnePK) { this.one= one; } @ManyToOne @PrimaryKeyJoinColumn(name="a_column_name") public Two getTwo() { return two; } public setTwo(Two two) { this.two = two; } } @Embeddable OnePK ( private int a; private int b; // get/set methods @Column("a_column_name") public getA() { return a; } }
either use @PrimaryKeyJoinColumn(name) or (referencedName) I don't remember which is the right one off the top of my head.