use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class CascadeNoBindingOnQuery method setup.
@Override
public void setup() {
this.shouldBindParameters = getSession().getLogin().shouldBindAllParameters();
OneToManyMapping mapping = (OneToManyMapping) getSession().getDescriptor(Employee.class).getMappingForAttributeName("phoneNumbers");
this.usesBatchReading = mapping.shouldUseBatchReading();
mapping.useBatchReading();
getSession().getLogin().setShouldBindAllParameters(true);
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class NoTargetForeignKeysSpecifiedTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.models.employee.domain.Employee.class);
descriptor.addTableName("EMPLOYEE");
// descriptor.addTableName("SALARY");
descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID");
// Descriptor properties.
descriptor.useFullIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteFullIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("EMP_ID");
descriptor.setSequenceNumberName("EMP_SEQ");
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("EMPLOYEE.EMP_ID");
descriptor.addMapping(idMapping);
OneToManyMapping managedEmployeesMapping = new OneToManyMapping();
managedEmployeesMapping.setAttributeName("managedEmployees");
managedEmployeesMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.Employee.class);
managedEmployeesMapping.useBasicIndirection();
// if the following is missing then the correct error will occure.
// managedEmployeesMapping.addTargetForeignKeyFieldName("EMPLOYEE.MANAGER_ID", "EMPLOYEE.EMP_ID");
// managedEmployeesMapping.setTargetForeignKeyFieldName();
descriptor.addMapping(managedEmployeesMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class InvalidContainerPolicyWithTransparentIndirectionTest method test.
@Override
public void test() {
TransparentIndirectionPolicy policy = new TransparentIndirectionPolicy();
OneToManyMapping mapping = new OneToManyMapping();
mapping.setAttributeName("manager");
mapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.Employee.class);
mapping.addTargetForeignKeyFieldName("EMPLOYEE.MANAGER_ID", "EMPLOYEE.EMP_ID");
policy.setMapping(mapping);
try {
policy.validateContainerPolicy(getSession().getIntegrityChecker());
} catch (EclipseLinkException exception) {
caughtException = exception;
}
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class ReturnAndMappingWithTransparentIndirectionMismatchTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.tests.validation.PersonWithValueHolder.class);
descriptor.addTableName("EMPLOYEE");
descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID");
// Descriptor properties.
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("p_id");
idMapping.setFieldName("EMPLOYEE.EMP_ID");
descriptor.addMapping(idMapping);
OneToManyMapping phoneNumbersMapping = new OneToManyMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.PhoneNumber.class);
phoneNumbersMapping.dontUseIndirection();
phoneNumbersMapping.useTransparentCollection();
phoneNumbersMapping.setSetMethodName("setPhones");
phoneNumbersMapping.setGetMethodName("getPhones");
// phoneNumbersMapping.privateOwnedRelationship();
phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMPLOYEE.EMP_ID");
descriptor.addMapping(phoneNumbersMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class ParameterAndMappingWithTransparentIndirectionMismatchTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.tests.validation.PersonWithValueHolder.class);
descriptor.addTableName("EMPLOYEE");
descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID");
// Descriptor properties.
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("p_id");
idMapping.setFieldName("EMPLOYEE.EMP_ID");
idMapping.setGetMethodName("getId");
idMapping.setSetMethodName("setId");
idMapping.getAttributeAccessor().initializeAttributes(PersonWithValueHolder.class);
descriptor.addMapping(idMapping);
OneToManyMapping phoneNumbersMapping = new OneToManyMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.PhoneNumber.class);
phoneNumbersMapping.dontUseIndirection();
phoneNumbersMapping.useTransparentCollection();
phoneNumbersMapping.setSetMethodName("setPhones");
phoneNumbersMapping.setGetMethodName("getPhones");
phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMPLOYEE.EMP_ID");
phoneNumbersMapping.getAttributeAccessor().initializeAttributes(PersonWithValueHolder.class);
descriptor.addMapping(phoneNumbersMapping);
return descriptor;
}
Aggregations