use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.
the class ParameterAndMappingWithIndirectionMismatchTest method setup.
@Override
protected void setup() {
expectedException = DescriptorException.parameterAndMappingWithIndirectionMismatch(new OneToOneMapping());
orgIntegrityChecker = getSession().getIntegrityChecker();
getSession().setIntegrityChecker(new IntegrityChecker());
getSession().getIntegrityChecker().dontCatchExceptions();
}
use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.
the class ParameterAndMappingWithIndirectionMismatchTest 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);
OneToOneMapping addressMapping = new OneToOneMapping();
addressMapping.setAttributeName("address");
addressMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.Address.class);
addressMapping.useBasicIndirection();
addressMapping.setGetMethodName("getAddress");
addressMapping.setSetMethodName("setAddress");
addressMapping.addForeignKeyFieldName("EMPLOYEE.ADDR_ID", "ADDRESS.ADDRESS_ID");
descriptor.addMapping(addressMapping);
// expectedException = DescriptorException.parameterAndMappingWithIndirectionMismatch(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.
the class ParameterAndMappingWithoutIndirectionMismatchTest 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");
descriptor.addMapping(idMapping);
OneToOneMapping addressMapping = new OneToOneMapping();
addressMapping.setAttributeName("address");
addressMapping.setReferenceClass(org.eclipse.persistence.testing.models.employee.domain.Address.class);
addressMapping.dontUseIndirection();
addressMapping.setGetMethodName("getAddressHolder");
addressMapping.setSetMethodName("setAddressHolder");
addressMapping.addForeignKeyFieldName("EMPLOYEE.ADDR_ID", "ADDRESS.ADDRESS_ID");
descriptor.addMapping(addressMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.
the class MissingMappingForFieldTest method test.
@Override
public void test() {
RelationalDescriptor descriptor = descriptor();
org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems person = new org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems();
OneToOneMapping dMapping = (OneToOneMapping) descriptor.getMappingForAttributeName("manager");
DatabaseField dField = dMapping.getForeignKeyFields().firstElement();
// the following causes the correct error to occure.
descriptor.getObjectBuilder().getMappingsByField().remove(dField);
try {
descriptor.getObjectBuilder().extractValueFromObjectForField(person, dField, (AbstractSession) getSession());
} catch (EclipseLinkException exception) {
caughtException = exception;
}
}
use of org.eclipse.persistence.mappings.OneToOneMapping in project eclipselink by eclipse-ee4j.
the class MissingMappingForFieldTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems.class);
descriptor.addTableName("EMPLOYEE");
descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID");
// Descriptor properties.
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteSoftCacheWeakIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("EMP_ID");
descriptor.setSequenceNumberName("EMP_SEQ");
descriptor.setAlias("EMPLOYEE");
DirectToFieldMapping idMapping = new DirectToFieldMapping();
idMapping.setAttributeName("id");
idMapping.setFieldName("EMPLOYEE.EMP_ID");
descriptor.addMapping(idMapping);
OneToOneMapping managerMapping = new OneToOneMapping();
managerMapping.setAttributeName("manager");
managerMapping.setReferenceClass(org.eclipse.persistence.testing.tests.validation.EmployeeWithProblems.class);
managerMapping.useBasicIndirection();
managerMapping.addForeignKeyFieldName("EMPLOYEE.MANAGER_ID", "EMPLOYEE.EMP_ID");
descriptor.addMapping(managerMapping);
return descriptor;
}
Aggregations