use of org.eclipse.persistence.mappings.DirectMapMapping in project eclipselink by eclipse-ee4j.
the class XMLForeignKeyTestSuite method testElementCollectionForeignKeys.
/**
* Tests an element collection foreign key settings.
*/
public void testElementCollectionForeignKeys() {
ClassDescriptor runnerDescriptor = getPersistenceUnitServerSession().getDescriptor(Runner.class);
DirectMapMapping mapping = (DirectMapMapping) runnerDescriptor.getMappingForAttributeName("endorsements");
OneToOneMapping keyMapping = (OneToOneMapping) ((MappedKeyMapContainerPolicy) mapping.getContainerPolicy()).getKeyMapping();
DatabaseTable table = mapping.getReferenceTable();
assertForeignKeyConstraint("FK_JPA21_XMLEndorsements", "FOREIGN KEY (ATHLETE_ID) REFERENCES JPA21_XML_DDL_RUNNER (ID)", table);
table = keyMapping.getForeignKeyFields().get(0).getTable();
assertForeignKeyConstraint("FK_JPA21_XMLEndorsements_Key", "FOREIGN KEY (ENDORSER_ID) REFERENCES JPA21_XML_DDL_ENDORSER (ID)", table);
mapping = (DirectMapMapping) runnerDescriptor.getMappingForAttributeName("accomplishments");
table = mapping.getReferenceTable();
assertForeignKeyConstraint("FK_JPA21_XMLAccomplishments", "FOREIGN KEY (ATHLETE_ID) REFERENCES JPA21_XML_DDL_RUNNER (ID)", table);
}
Aggregations