use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class CascadeNoBindingOnQuery method reset.
@Override
public void reset() {
getSession().getLogin().setShouldBindAllParameters(this.shouldBindParameters);
OneToManyMapping mapping = (OneToManyMapping) getSession().getDescriptor(Employee.class).getMappingForAttributeName("phoneNumbers");
mapping.setUsesBatchReading(this.usesBatchReading);
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class DynamicEmployeeSystem method configureEmployee.
private static void configureEmployee(DynamicTypeBuilder employee, DynamicTypeBuilder address, DynamicTypeBuilder phone, DynamicTypeBuilder period, DynamicTypeBuilder project) {
employee.setPrimaryKeyFields("EMP_ID");
employee.addDirectMapping("id", int.class, "D_EMPLOYEE.EMP_ID");
employee.addDirectMapping("firstName", String.class, "D_EMPLOYEE.F_NAME");
employee.addDirectMapping("lastName", String.class, "D_EMPLOYEE.L_NAME");
employee.addDirectMapping("gender", String.class, "D_EMPLOYEE.GENDER");
employee.addDirectMapping("salary", int.class, "D_SALARY.SALARY");
OneToOneMapping addressMapping = employee.addOneToOneMapping("address", address.getType(), "ADDR_ID");
addressMapping.setCascadeAll(true);
addressMapping.setIsPrivateOwned(true);
employee.addOneToOneMapping("manager", employee.getType(), "MANAGER_ID");
OneToManyMapping phoneMapping = employee.addOneToManyMapping("phoneNumbers", phone.getType(), "EMP_ID");
phoneMapping.setCascadeAll(true);
phoneMapping.setIsPrivateOwned(true);
employee.addAggregateObjectMapping("period", period.getType(), true);
employee.addOneToManyMapping("managedEmployees", employee.getType(), "MANAGER_ID");
employee.configureSequencing("EMP_SEQ", "EMP_ID");
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class MappingConfigTestSuite method verifyEmployeeDescriptor.
@Test
public void verifyEmployeeDescriptor() {
ClassDescriptor descriptor = session.getDescriptorForAlias("Employee");
assertNotNull(descriptor);
assertEquals("Employee", descriptor.getAlias());
assertNull(descriptor.getInheritancePolicyOrNull());
// Address Mapping
OneToOneMapping addrMapping = (OneToOneMapping) descriptor.getMappingForAttributeName("address");
assertNotNull(addrMapping);
assertTrue(addrMapping.isPrivateOwned());
assertEquals(session.getDescriptorForAlias("Address"), addrMapping.getReferenceDescriptor());
// PhoneNumber Mapping
OneToManyMapping phoneMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("phoneNumbers");
assertNotNull(phoneMapping);
assertTrue(phoneMapping.isPrivateOwned());
assertEquals(session.getDescriptorForAlias("PhoneNumber"), phoneMapping.getReferenceDescriptor());
// Manager Mapping
OneToOneMapping managerMapping = (OneToOneMapping) descriptor.getMappingForAttributeName("manager");
assertNotNull(managerMapping);
assertFalse(managerMapping.isPrivateOwned());
assertEquals(descriptor, managerMapping.getReferenceDescriptor());
// Managed Employees Mapping
OneToManyMapping managedEmployeesMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("managedEmployees");
assertNotNull(managedEmployeesMapping);
assertFalse(managedEmployeesMapping.isPrivateOwned());
assertEquals(descriptor, managedEmployeesMapping.getReferenceDescriptor());
// Projects Mapping
ManyToManyMapping projectsMapping = (ManyToManyMapping) descriptor.getMappingForAttributeName("projects");
assertNotNull(projectsMapping);
assertFalse(projectsMapping.isPrivateOwned());
assertEquals(session.getDescriptorForAlias("Project"), projectsMapping.getReferenceDescriptor());
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class SetMethodParameterTypeNotValidTest method test.
@Override
public void test() {
try {
getSession().setIntegrityChecker(new IntegrityChecker());
getSession().getIntegrityChecker().dontCatchExceptions();
// the following causes the correct error to occure.
RelationalDescriptor descriptor = descriptor();
OneToManyMapping dMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("managedEmployeesWithProblems");
org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems person = new org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems();
NoIndirectionPolicy indirectionPolicy = (NoIndirectionPolicy) dMapping.getIndirectionPolicy();
indirectionPolicy.validateSetMethodParameterTypeForCollection(org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems.class, getSession().getIntegrityChecker());
} catch (EclipseLinkException exception) {
caughtException = exception;
}
}
use of org.eclipse.persistence.mappings.OneToManyMapping in project eclipselink by eclipse-ee4j.
the class EmployeeSubProject method buildEmployeeDescriptor.
@Override
public ClassDescriptor buildEmployeeDescriptor() {
ClassDescriptor descriptor = super.buildEmployeeDescriptor();
DirectToFieldMapping lastNameMapping = (DirectToFieldMapping) descriptor.getMappingForAttributeName("lastName");
lastNameMapping.setNullValue(null);
OneToManyMapping addressMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("phoneNumbers");
addressMapping.addAscendingOrdering("id");
OneToManyMapping managedEmployeeMapping = (OneToManyMapping) descriptor.getMappingForAttributeName("managedEmployees");
managedEmployeeMapping.addDescendingOrdering("id");
TransformationMapping normalHoursMapping = (TransformationMapping) descriptor.getMappingForAttributeName("normalHours");
normalHoursMapping.useContainerIndirection(Vector.class);
return descriptor;
}
Aggregations