Search in sources :

Example 6 with OneToOneMapping

use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.

the class BidirectionalRelationshipProject method buildPlayerDescriptor.

public RelationalDescriptor buildPlayerDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(Player.class);
    descriptor.addTableName("PLAYER");
    descriptor.addPrimaryKeyFieldName("PLAYER.ID");
    descriptor.setAlias("Player");
    // RelationalDescriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("m_id");
    idMapping.setFieldName("PLAYER.ID");
    descriptor.addMapping(idMapping);
    OneToOneMapping onetoonemapping = new OneToOneMapping();
    onetoonemapping.setAttributeName("m_team");
    onetoonemapping.setReferenceClass(Team.class);
    onetoonemapping.useBasicIndirection();
    onetoonemapping.addForeignKeyFieldName("PLAYER.TEAM_ID", "TEAM.ID");
    onetoonemapping.setRelationshipPartnerAttributeName("m_players");
    descriptor.addMapping(onetoonemapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 7 with OneToOneMapping

use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.

the class ConcurrentLargeProject method descriptor.

public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    /* First define the class, table and descriptor properties. */
    descriptor.setJavaClass(ConcurrentLargeProject.class);
    descriptor.setTableName("CONCURRENT_PROJECT");
    // Inheritance Properties.
    descriptor.getInheritancePolicy().setParentClass(ConcurrentProject.class);
    OneToOneMapping supervisorMapping = new OneToOneMapping();
    supervisorMapping.setAttributeName("supervisor");
    supervisorMapping.setReferenceClass(ConcurrentPerson.class);
    supervisorMapping.setGetMethodName("getSupervisor");
    supervisorMapping.setSetMethodName("setSupervisor");
    supervisorMapping.dontUseIndirection();
    supervisorMapping.addTargetForeignKeyFieldName("CONCURRENT_EMP.PROJ_ID", "CONCURRENT_PROJECT.ID");
    descriptor.addMapping(supervisorMapping);
    OneToOneMapping locationMapping = new OneToOneMapping();
    locationMapping.setAttributeName("location");
    locationMapping.setReferenceClass(ConcurrentAddress.class);
    locationMapping.setGetMethodName("getLocation");
    locationMapping.setSetMethodName("setLocation");
    locationMapping.dontUseIndirection();
    locationMapping.addForeignKeyFieldName("CONCURRENT_PROJECT.LOCATION_ID", "CONCURRENT_ADDRESS.ADDRESS_ID");
    descriptor.addMapping(locationMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 8 with OneToOneMapping

use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.

the class IsolatedEmployeeProject method buildIsolatedChildDescriptor.

public RelationalDescriptor buildIsolatedChildDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(IsolatedChild.class);
    descriptor.addTableName("ISOLATED_CHILD");
    descriptor.addPrimaryKeyFieldName("ISOLATED_CHILD.ID");
    // ClassDescriptor Properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteFullIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ISOLATED_CHILD.ID");
    descriptor.setSequenceNumberName("CHILD_SEQ");
    // IMPORTANT!
    descriptor.alwaysConformResultsInUnitOfWork();
    descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
    descriptor.setAlias("IsolatedChild");
    descriptor.setCacheSynchronizationType(ClassDescriptor.DO_NOT_SEND_CHANGES);
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Event Manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ISOLATED_CHILD.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping serialMapping = new DirectToFieldMapping();
    serialMapping.setAttributeName("serial");
    serialMapping.setFieldName("ISOLATED_CHILD.SERIAL");
    descriptor.addMapping(serialMapping);
    DirectToFieldMapping deletedMapping = new DirectToFieldMapping();
    deletedMapping.setAttributeName("deleted");
    deletedMapping.setFieldName("ISOLATED_CHILD.DELETED");
    descriptor.addMapping(deletedMapping);
    OneToOneMapping parentMapping = new OneToOneMapping();
    parentMapping.setAttributeName("parent");
    parentMapping.setReferenceClass(IsolatedParent.class);
    parentMapping.useBasicIndirection();
    parentMapping.addForeignKeyFieldName("ISOLATED_CHILD.PARENT_ID", "ISOLATED_PARENT.ID");
    descriptor.addMapping(parentMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 9 with OneToOneMapping

use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.

the class IsolatedEmployeeProject method buildIsolatedBoneClassDescriptor.

public ClassDescriptor buildIsolatedBoneClassDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(IsolatedBone.class);
    descriptor.addTableName("ISOLATED_BONE");
    descriptor.addPrimaryKeyFieldName("ISOLATED_BONE.ID");
    // ClassDescriptor Properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteFullIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.alwaysConformResultsInUnitOfWork();
    descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
    descriptor.setAlias("IsolatedBone");
    descriptor.setCacheSynchronizationType(ClassDescriptor.DO_NOT_SEND_CHANGES);
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Event Manager.
    // Mappings.
    DirectToFieldMapping colorMapping = new DirectToFieldMapping();
    colorMapping.setAttributeName("color");
    colorMapping.setFieldName("ISOLATED_BONE.COLOR");
    descriptor.addMapping(colorMapping);
    DirectToFieldMapping deletedMapping = new DirectToFieldMapping();
    deletedMapping.setAttributeName("deleted");
    deletedMapping.setFieldName("ISOLATED_BONE.DELETED");
    descriptor.addMapping(deletedMapping);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ISOLATED_BONE.ID");
    descriptor.addMapping(idMapping);
    OneToOneMapping ownerMapping = new OneToOneMapping();
    ownerMapping.setAttributeName("owner");
    ownerMapping.setReferenceClass(IsolatedDog.class);
    ownerMapping.useBasicIndirection();
    ownerMapping.addForeignKeyFieldName("ISOLATED_BONE.DOG_ID", "ISOLATED_DOG.ID");
    descriptor.addMapping(ownerMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Example 10 with OneToOneMapping

use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.

the class MapCollectionsProject method buildAEOTMValueDescriptor.

protected void buildAEOTMValueDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(AEOTMMapValue.class);
    Vector vector = new Vector();
    vector.addElement("AE_OM_ENT_MAP_VALUE");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("AE_OM_ENT_MAP_VALUE.ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("AE_OM_ENT_MAP_VALUE.ID");
    descriptor.addMapping(directtofieldmapping);
    OneToOneMapping holderMapping = new OneToOneMapping();
    holderMapping.setAttributeName("holder");
    holderMapping.setReferenceClass(AggregateEntity1MMapHolder.class);
    holderMapping.useBasicIndirection();
    holderMapping.setGetMethodName("getHolder");
    holderMapping.setSetMethodName("setHolder");
    holderMapping.addForeignKeyFieldName("AE_OM_ENT_MAP_VALUE.HOLDER_ID", "AGG_ENT_1M_MAP_HOLDER.ID");
    descriptor.addMapping(holderMapping);
    addDescriptor(descriptor);
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) OneToOneMapping(org.eclipse.persistence.mappings.OneToOneMapping)

Aggregations

OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)97 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)38 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)32 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)27 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)24 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)17 DatabaseTable (org.eclipse.persistence.internal.helper.DatabaseTable)15 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)15 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)15 Vector (java.util.Vector)11 Expression (org.eclipse.persistence.expressions.Expression)8 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 DirectCollectionMapping (org.eclipse.persistence.mappings.DirectCollectionMapping)5 DirectMapMapping (org.eclipse.persistence.mappings.DirectMapMapping)5 SessionBroker (org.eclipse.persistence.sessions.broker.SessionBroker)5 Test (org.junit.Test)5 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)4 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)4 RelationTableMechanism (org.eclipse.persistence.mappings.RelationTableMechanism)4