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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations