Search in sources :

Example 16 with DirectMapMapping

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);
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) DatabaseTable(org.eclipse.persistence.internal.helper.DatabaseTable) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping) DirectMapMapping(org.eclipse.persistence.mappings.DirectMapMapping)

Aggregations

DirectMapMapping (org.eclipse.persistence.mappings.DirectMapMapping)16 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)6 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)5 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)4 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)4 DatabaseTable (org.eclipse.persistence.internal.helper.DatabaseTable)4 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)4 TransparentIndirectionPolicy (org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy)3 AggregateCollectionMapping (org.eclipse.persistence.mappings.AggregateCollectionMapping)2 CollectionMapping (org.eclipse.persistence.mappings.CollectionMapping)2 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)2 DirectCollectionMapping (org.eclipse.persistence.mappings.DirectCollectionMapping)2 JoinTable (com.blazebit.persistence.spi.JoinTable)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Vector (java.util.Vector)1