This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 224634 - Add OneToOnes targeting non id fields and foreign target relationships support to the EclipseLink-ORM.XML Schema
Summary: Add OneToOnes targeting non id fields and foreign target relationships suppor...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 325781
  Show dependency tree
 
Reported: 2008-03-28 10:48 EDT by Chris Delahunt CLA
Modified: 2022-06-09 10:30 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Delahunt CLA 2008-03-28 10:48:41 EDT
EclipseLink supports foreign keys referencing non-id fields in OneToOne mappings, but ORM.xml doesn't.  ORM.xml assumes that the referenced target field is in the target entity's main table, limiting options.  

Related to this, OneToOneMappings support target foreign key relationships without requiring a backpointer OneToOneMapping.  ORM.xml needs a way to indicate that a OneToOne is using a foreign target key relationship without relying on the mapped by indicator, as EclipseLink should allow any mappping type to set the foreign key.  

Putting the target table in the join column should help resolving both these issues, as well as another field to allow indicating its a target foreign key when the 1:1 is self referencing.  

ie
  PhoneNumber has emp_id basic mapping
  Employee has 1:1 to phoneNumber using PhoneNumber's emp_id as the foreign key

This is allowed in EclipseLink mappings, but cannot be mapped in ORM.xml
Comment 1 Tom Ware CLA 2009-04-16 10:59:34 EDT
Updating priority due to revised bug categorization process.  See the following page for details:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines#Priority_and_Target_Milestone 

If you feel the updated priority is incorrect, please send an email to eclipselink-users@eclipse.org.
Comment 2 Doug Clarke CLA 2009-12-07 15:36:20 EST
Can we support this using:

1. Allow the @JoinColumn's referencedColumnName specify non ID columns

2. For multi-table mappings allow referencedColumnName to be table qualified
Comment 3 Chris Delahunt CLA 2009-12-08 11:46:56 EST
Allowing the table qualifer to be added and allowing non ID columns solves half
the problem.  The other half though is that there is no way to specify that the
relationship is target foreign key relationship as in native EclipseLink
mappings.  

Currently, the only way to specify that the target entity/table has the foreign
key is to use the mappedby setting, which requires a valid OneToOne/ManyToOne
relationship on the target entity.  Using the previous example, for the
Employee -> PhoneNumber to use the mappedby flag indicating the foreign key is
in the PHONE table, PhoneNumber must have a 1:1 to Employee.  

So this request is to allow non-id fields be used, and mappedby (or some other
mechanism to indicate a native EclipseLink foreign target key relationships)
used on unidirectional relationships.
Comment 4 Guy Pelletier CLA 2010-02-22 15:55:31 EST
Updating priority due to revised bug categorization process.  See the following
page for details:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines#Priority_and_Target_Milestone 

If you feel the updated priority is incorrect, please send an email to
eclipselink-users@eclipse.org.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:30:25 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink