Unfortunately this is not something JPA handles very gracefully.
see,
[
http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Primary_Keys_through_OneToOne_Relationships]
In TopLink Essentials you cannot currently annotate a ToOne with an @Id,
however you can use a DescriptorCustomizer to set your primaryKeyFields in
your ClassDescriptor to include the foreign key.
Hopefully JPA 2.0 will support this common model better.
Markus KARG-3 wrote:
>
> We need to have a entity primary key pointing to another entity (typical
> master-detail construction).
>
>
>
> Is it possible to do:
>
>
>
> @Id
>
> private MyMasterEntity;
>
>
>
> ?
>
>
>
> Also for legacy reasons we need a PK class. Is it possible to have private
> MyMasterEntity as a field in the PK class, or how to deal with that?
>
>
>
> Thanks
>
> Markus
>
>
>
> QUIPSY QUALITY GmbH & Co. KG
>
> Ein Unternehmen der MES-Gruppe
>
> Stuttgarter Strasse 23
>
> D-75179 Pforzheim
>
> Tel: 07231-9189-52
>
> Fax: 07231-9189-59
>
> www.quipsy.de
>
> karg_at_quipsy.de
>
> Registergericht Mannheim HRA 701214
>
> Geschäftsführer: Nils Schroeder
>
>
>
> Diese E-Mail enthält persönliche, vertrauliche und vor Weitergabe
> geschützte Informationen und ist ausschließlich für den vorgesehenen o.g.
> Empfänger (Adressaten) bestimmt. Falls Sie diese E-Mail versehentlich
> erhalten haben und nicht der vorgesehene Empfänger sind, bitten wir Sie,
> die E-Mail und deren Anhänge nicht aufzubewahren, nicht zu
> vervielfältigen, nicht zu nutzen und nicht weiterzugeben. Bitte
> informieren Sie uns als Absender über diesen Zustellungsfehler und löschen
> Sie die E-Mail.
>
>
>
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Primary-Key-references-entity-tp17794385p17800626.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.