[jboss-user] [EJB 3.0] - Composite Key is made up by foreign keys
mrchit_2000
do-not-reply at jboss.com
Fri Feb 23 03:04:50 EST 2007
Hi all,
I have problem finding out how to specify the member of the composite key are foreign keys pointing to primary key of other tables.
For example, If my composite key have 2 columns (A,B). I created wrapper like
public final class CompKey implements Serializable {
private int A;
private int B;
public boolean equals(Object obj) {
..............
}
public int hashcode() {
...........
}
}
Then in my class I will use
@IdClass(CompKey.class)
@Entity
public class MyClass implements Serializable{
private int A;
private int B;
}
But now I want to specify A and B as foreign keys, how do I do that? I tried using @JoinColumn and add 2 more fields to class MyClass but that gives me error saying the column names A and B are repeated.
Can someone tell me how to specify A and B as foreign key but can still use them as composite key at the same time?
Thank you very much in advance,
Lngo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4021009#4021009
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4021009
More information about the jboss-user
mailing list