Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic question on composite id.

 
Arjun Abhishek
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 entity classes as below.

1. Student
private int id // This is the PK for this table
// In the mapping i am using the generated id
2. Course
private int id // This is the PK for this table
// In the mapping i am using the generated id
3. Result
private Student student
private Course course
private int uniqueNumber // All the 3 field are to be part of the composite id.

What should be the mapping in the result.hbm.xml

thanks
Arjun.
 
Reehan Lalkhanwar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Something like this.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as a helpful tip, if you have some complex mappings, The Hibernate Tools download provides some great Eclipse plugins that will automatically generate mappings for complex relationships and complex surrogate and composite keys.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic