Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Development/JPA2.0/one-to-one via jointable"
(New page: = Updated EntityManager / Query APIs = JPA 2.0 Root | [http://bugs.eclipse.org/282553 Enhancement Request] ==Issue Summary== In JPA 2.0 the specific...) |
(→Core) |
||
Line 12: | Line 12: | ||
===Core=== | ===Core=== | ||
Add relation table (JoinTable) support for OneToOneMapping. | Add relation table (JoinTable) support for OneToOneMapping. | ||
− | |||
<source lang="java"> | <source lang="java"> | ||
OneToOneMapping addressMapping = new OneToOneMapping(); | OneToOneMapping addressMapping = new OneToOneMapping(); | ||
... | ... | ||
+ | addressMapping.setRelationTableMechanism(new RelationTableMechanism()); | ||
addressMapping.setRelationTableName("EMP_ADDRESS"); | addressMapping.setRelationTableName("EMP_ADDRESS"); | ||
− | addressMapping.addSourceRelationKeyFieldName("EMP_ADDRESS.EMP_ID", "EMPLOYEE.EMP_ID"); | + | addressMapping.getRelationTableMechanism().addSourceRelationKeyFieldName("EMP_ADDRESS.EMP_ID", "EMPLOYEE.EMP_ID"); |
− | addressMapping.addTargetRelationKeyFieldName("EMP_ADDRESS.ADDR_ID", "ADDRESS.ADDRESS_ID"); | + | addressMapping.getRelationTableMechanism().addTargetRelationKeyFieldName("EMP_ADDRESS.ADDR_ID", "ADDRESS.ADDRESS_ID"); |
descriptor.addMapping(addressMapping); | descriptor.addMapping(addressMapping); | ||
</source> | </source> | ||
In bidirectional case one of the two mappings must be read only. | In bidirectional case one of the two mappings must be read only. | ||
OneToManyMapping with relation table could be paired with either OneToManyMapping or ManyToManyMapping. | OneToManyMapping with relation table could be paired with either OneToManyMapping or ManyToManyMapping. | ||
+ | ====Limitations==== | ||
+ | No HistoryPolicy support for OneToOneMapping's relation table. | ||
==Work Required== | ==Work Required== | ||
==Implementation Details== | ==Implementation Details== | ||
== Open Issues == | == Open Issues == |
Latest revision as of 17:03, 14 July 2009
Contents
Updated EntityManager / Query APIs
JPA 2.0 Root | Enhancement Request
Issue Summary
In JPA 2.0 the specification states (11.1.23 JoinTable Annotation): The JoinTable annotation is used in the mapping of entity associations. A JoinTable annotation is specified on the owning side of the association. A join table is typically used in the mapping of many-to-many and unidirectional one-to-many associations. It may also be used to map bidirectional many-to-one/one-to-many associations and one-to-one associations (both bidirectional and unidirectional).
General Solution
Core
Add relation table (JoinTable) support for OneToOneMapping.
OneToOneMapping addressMapping = new OneToOneMapping(); ... addressMapping.setRelationTableMechanism(new RelationTableMechanism()); addressMapping.setRelationTableName("EMP_ADDRESS"); addressMapping.getRelationTableMechanism().addSourceRelationKeyFieldName("EMP_ADDRESS.EMP_ID", "EMPLOYEE.EMP_ID"); addressMapping.getRelationTableMechanism().addTargetRelationKeyFieldName("EMP_ADDRESS.ADDR_ID", "ADDRESS.ADDRESS_ID"); descriptor.addMapping(addressMapping);
In bidirectional case one of the two mappings must be read only. OneToManyMapping with relation table could be paired with either OneToManyMapping or ManyToManyMapping.
Limitations
No HistoryPolicy support for OneToOneMapping's relation table.