How to use a composite key as foreign key in table using JPA.
Say, I have a table u with a,b as composite key. There are other fields though. There is another table, say V, in which a will be a foreign key.
How to use a composite key as foreign key in table using JPA.
Say, I have a table u with a,b as composite key. There are other fields though. There is another table, say V, in which a will be a foreign key.
Use an @IdClass
or an @EmbeddedId
.
Check out http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#JPA_2.0 and Which annotation should I use: @IdClass or @EmbeddedId.