Other options include using the @IdClass annotation or @EmbeddedId. This tutorial covers each of them. But that other field needs to be treated somehow.

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183

posted Oct 19, 2010 02:36:19

0

Thanks, the tutorial was very helpful. I was able to get the composite key setup.

I have a couple of questions though.
1. The tutorial does not show how list can be retrieved for a composite key instead of

2. I have noticed @Id being used for the getter instead of the variable in many examples. Is there any advantage in doing this.

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183

posted Oct 20, 2010 00:39:46

0

Forget it, I figured out how to retrieve the hibernate objects from the composite key.

I had a question on how to display data which is a combination of YearDepartment and DepartmentMonths. DepartmentMonths is like a join table between YearDepartment and Manager which has additional data.