• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How make Entity with composite primary key in some other Entity's primary key?

 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have entity called Entity1 which have composite primary keys id1 and id2. In here I used primary key class called Entity1Id.
And I have Other entity called Entity2 which also have 2 primary keys. And in that Entity2 one primary key should be Entity1's instance(as a foreign key).

My problem is how I make Entity2 - with making Entity1's foreign key as it's composite primary key member?
 
Udara Amarasinghe
Ranch Hand
Posts: 109
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sutherland wrote:You can use @Id on a OneToOne or ManyToOne relationship to cascade an id.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Primary_Keys_through_OneToOne_and_ManyToOne_Relationships

Thank you very much James . I already solved It.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic