Community
Participate
Working Groups
As per spec. (11.1.23 JoinTable Annotation): 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.
Created attachment 140894 [details] Suggested patch. Lots of code copied from ManyToManyMapping. A new OneToOneJoinTableEmployeeBasicTestModel is created.
Created attachment 141454 [details] Corrected patch The corrected patch declares a new class RelationTableMethod that holds all the relation table - related functionality (which is now shared between ManyToMany and OneToOne). Now the user can setup relation table in the same way on OneToOne and ManyToMany: addressMapping.setRelationTableMechanism(new RelationTableMechanism()); addressMapping.getRelationTableMechanism().setRelationTableName("OTOJT_EMP_ADDRESS"); addressMapping.getRelationTableMechanism().addSourceRelationKeyFieldName("OTOJT_EMP_ADDRESS.EMP_ID", "OTOJT_EMPLOYEE.EMP_ID"); addressMapping.getRelationTableMechanism().addTargetRelationKeyFieldName("OTOJT_EMP_ADDRESS.ADDR_ID", "OTOJT_ADDRESS.ADDRESS_ID"); This is the only possible way to set up relation table on OneToOneMapping, but on ManyToManyMapping the "old" way could be used, too: projectsMapping.setRelationTableName("OTOJT_PROJ_EMP"); projectsMapping.addSourceRelationKeyFieldName("OTOJT_PROJ_EMP.EMP_ID", "OTOJT_EMPLOYEE.EMP_ID"); projectsMapping.addTargetRelationKeyFieldName("OTOJT_PROJ_EMP.PROJ_ID", "OTOJT_PROJECT.PROJ_ID"); Added some expression tests.
Link to the doc: http://wiki.eclipse.org/EclipseLink/Development/JPA2.0/one-to-one_via_jointable
Created attachment 141794 [details] Final patch. Moved relation row building ifrom mappings nto RelationMechanism class. The patch checked into trunk.
Fixed.
Created attachment 141919 [details] Correction patch. Some 13 tests that I added failed on MySql. This patch corrects the problems: 1. EmployeePopulator didn't round times causing comparison to fail - it's a test problem; 2. BatchRead code that extracts source keys from relation table didn't convert them using source field type - that caused read objects not found in the map of batched objects (CacheKey that has is not equal to the one with BigDecimal); 3. SQLSelectStatement.appendFromClauseForOuterJoin failed to use relation table in OneToOne case - now the same code is shared between ManyToMany and OneToOne with relation table.
Correction patch checked into trunk.
Re-opening the bug as the metadata processing portion of this bug have not been completed and will be submitted against this bug.
*** Bug 265319 has been marked as a duplicate of this bug. ***
Created attachment 148341 [details] JPA metadata processing implementation
Changes have been submitted. Reviewed by: Tom Ware Tests: New test (testOne2OneRelationTables) added to both EntityMappingsRelationshipsJUnitTestCase and RelationshipModelJUnitTestSuite
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink