This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Composite key classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Composite key classes" Watch "Composite key classes" New topic

Composite key classes

Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106


do composite key classes have to follow the JavaBean specification, that is, do they have to have getters and setters?


OCJP JavaSE 6 (86%)
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
By composite key class I assume you mean the JPA IdClass?

The IdClass in JPA must match your Entity Id fields. So if you use field access (annotated the fields) then your IdClass only needs the fields, does not need to methods (although your app may still want the methods). If you use property access (annotate the methods), then your IdClass must have those same methods.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
I agree. Here's the link:
subject: Composite key classes
It's not a secret anymore!