permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes PK in aggregated entity with other non-key attributes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "PK in aggregated entity with other non-key attributes?" Watch "PK in aggregated entity with other non-key attributes?" New topic
Author

PK in aggregated entity with other non-key attributes?

Shannon McGee
Greenhorn

Joined: Oct 01, 2009
Posts: 18
Is it possible to push the PK down into an aggregated entity that contains other non-key attributes?

@IdClass and @EmbeddedId allow you to define a PK (or composite key) in an aggregated entity.


But is it possible to map something like:



And yes, I know this is just a bad idea

Thanks!
Shannon
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
The JPA spec does not allow this, but some providers may support it.

If using EclipseLink you can use the @PrimaryKey annotation to define your primary key to any desired columns, no matter how they are mapped.

Probably best to mirror the id field in the entity.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PK in aggregated entity with other non-key attributes?
 
Similar Threads
@OneToMany primary key part of foreign key
JPA Mapping Exception
Primary key / Forign Key
EJB3 Beta Certification - EntityManager BASIC notes. (PART II)
@ManyToOne - extra column?