Search in sources :

Example 76 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class IsolatedEmployeeProject method buildAddressDescriptor.

public RelationalDescriptor buildAddressDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.tests.isolatedsession.IsolatedAddress.class);
    descriptor.addTableName("ISOLATED_ADDRESS");
    descriptor.addPrimaryKeyFieldName("ISOLATED_ADDRESS.ADDRESS_ID");
    // Descriptor properties.
    descriptor.setSequenceNumberFieldName("ADDRESS_ID");
    descriptor.setSequenceNumberName("ADDRESS_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping cityMapping = new DirectToFieldMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setFieldName("ISOLATED_ADDRESS.CITY");
    descriptor.addMapping(cityMapping);
    DirectToFieldMapping countryMapping = new DirectToFieldMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setFieldName("ISOLATED_ADDRESS.COUNTRY");
    descriptor.addMapping(countryMapping);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ISOLATED_ADDRESS.ADDRESS_ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping postalCodeMapping = new DirectToFieldMapping();
    postalCodeMapping.setAttributeName("postalCode");
    postalCodeMapping.setFieldName("ISOLATED_ADDRESS.P_CODE");
    descriptor.addMapping(postalCodeMapping);
    DirectToFieldMapping provinceMapping = new DirectToFieldMapping();
    provinceMapping.setAttributeName("province");
    provinceMapping.setFieldName("ISOLATED_ADDRESS.PROVINCE");
    descriptor.addMapping(provinceMapping);
    DirectToFieldMapping streetMapping = new DirectToFieldMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setFieldName("ISOLATED_ADDRESS.STREET");
    descriptor.addMapping(streetMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 77 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor 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 78 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class MasterSlaveProject method buildSlaveDescriptor.

public RelationalDescriptor buildSlaveDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.tests.remote.Slave.class);
    descriptor.addTableName("SLAVE");
    descriptor.addPrimaryKeyFieldName("SLAVE.id");
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping MyPrimaryKeyMapping = new DirectToFieldMapping();
    MyPrimaryKeyMapping.setAttributeName("primaryKey");
    MyPrimaryKeyMapping.setFieldName("SLAVE.id");
    descriptor.addMapping(MyPrimaryKeyMapping);
    OneToOneMapping masterMapping = new OneToOneMapping();
    masterMapping.setAttributeName("master");
    masterMapping.setReferenceClass(org.eclipse.persistence.testing.tests.remote.Master.class);
    masterMapping.dontUseIndirection();
    masterMapping.addForeignKeyFieldName("SLAVE.mid", "MASTER.id");
    descriptor.addMapping(masterMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 79 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class ALCTEmployeeProject method buildEmploymentPeriodDescriptor.

public ClassDescriptor buildEmploymentPeriodDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.descriptorIsAggregate();
    descriptor.setJavaClass(ALCTEmploymentPeriod.class);
    // Descriptor Properties.
    descriptor.setAlias("EmploymentPeriod");
    // Change Tracking
    descriptor.setObjectChangePolicy(new AttributeChangeTrackingPolicy());
    // Cache Invalidation Policy
    // Query Manager.
    // Named Queries.
    // Event Manager.
    // Mappings.
    DirectToFieldMapping endDateMapping = new DirectToFieldMapping();
    endDateMapping.setAttributeName("endDate");
    endDateMapping.setFieldName("endDate->DIRECT");
    descriptor.addMapping(endDateMapping);
    DirectToFieldMapping startDateMapping = new DirectToFieldMapping();
    startDateMapping.setAttributeName("startDate");
    startDateMapping.setFieldName("startDate->DIRECT");
    descriptor.addMapping(startDateMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) AttributeChangeTrackingPolicy(org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy)

Example 80 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class ALCTEmployeeProject method buildEmployeeDescriptor.

public ClassDescriptor buildEmployeeDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(ALCTEmployee.class);
    descriptor.addTableName("ALCTEMPLOYEE");
    descriptor.addPrimaryKeyFieldName("ALCTEMPLOYEE.EMP_ID");
    // Descriptor Properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ALCTEMPLOYEE.EMP_ID");
    descriptor.setSequenceNumberName("EMP_SEQ");
    VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
    lockingPolicy.setWriteLockFieldName("ALCTEMPLOYEE.VERSION");
    descriptor.setOptimisticLockingPolicy(lockingPolicy);
    descriptor.setAlias("ALCTEmployee");
    // Change Tracking
    descriptor.setObjectChangePolicy(new AttributeChangeTrackingPolicy());
    // Cache Invalidation Policy
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    descriptor.getQueryManager().setQueryTimeout(0);
    // Named Queries.
    // Event Manager.
    // Mappings.
    DirectToFieldMapping firstNameMapping = new DirectToFieldMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setFieldName("ALCTEMPLOYEE.F_NAME");
    firstNameMapping.setNullValue("");
    descriptor.addMapping(firstNameMapping);
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ALCTEMPLOYEE.EMP_ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping lastNameMapping = new DirectToFieldMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setFieldName("ALCTEMPLOYEE.L_NAME");
    lastNameMapping.setNullValue("");
    descriptor.addMapping(lastNameMapping);
    DirectToFieldMapping genderMapping = new DirectToFieldMapping();
    genderMapping.setAttributeName("gender");
    genderMapping.setFieldName("ALCTEMPLOYEE.GENDER");
    ObjectTypeConverter genderMappingConverter = new ObjectTypeConverter();
    genderMappingConverter.addConversionValue("F", "Female");
    genderMappingConverter.addConversionValue("M", "Male");
    genderMapping.setConverter(genderMappingConverter);
    descriptor.addMapping(genderMapping);
    AggregateObjectMapping periodMapping = new AggregateObjectMapping();
    periodMapping.setAttributeName("period");
    periodMapping.setReferenceClass(ALCTEmploymentPeriod.class);
    periodMapping.setIsNullAllowed(true);
    periodMapping.addFieldNameTranslation("ALCTEMPLOYEE.END_DATE", "endDate->DIRECT");
    periodMapping.addFieldNameTranslation("ALCTEMPLOYEE.START_DATE", "startDate->DIRECT");
    descriptor.addMapping(periodMapping);
    return descriptor;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) AggregateObjectMapping(org.eclipse.persistence.mappings.AggregateObjectMapping) VersionLockingPolicy(org.eclipse.persistence.descriptors.VersionLockingPolicy) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter) AttributeChangeTrackingPolicy(org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy)

Aggregations

RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)306 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)122 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)43 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)26 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)19 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)18 Vector (java.util.Vector)17 TransparentIndirectionPolicy (org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy)15 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)15 TransformationMapping (org.eclipse.persistence.mappings.TransformationMapping)13 IntegrityChecker (org.eclipse.persistence.exceptions.IntegrityChecker)12 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)10 java.util (java.util)9 AggregateObjectMapping (org.eclipse.persistence.mappings.AggregateObjectMapping)8 org.eclipse.persistence.mappings (org.eclipse.persistence.mappings)7 UnidirectionalOneToManyMapping (org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)6 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)6 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)6 DirectCollectionMapping (org.eclipse.persistence.mappings.DirectCollectionMapping)5 DirectMapMapping (org.eclipse.persistence.mappings.DirectMapMapping)4