This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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
Similar Threads
Update with Composite keys
Hibernate many-to-one composite key as foreign key
One-to-many mapping using SET
Composite key mapping
Composite Primary Key in CMP Bean??