use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class ErrorOccuredInAmendmentMethodTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.models.employee.domain.PhoneNumber.class);
descriptor.addTableName("PHONE");
descriptor.addPrimaryKeyFieldName("PHONE.TYPE");
// Descriptor properties.
descriptor.useFullIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteFullIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setAmendmentClass(AmendmentClass.class);
descriptor.setAmendmentMethodName("modifyPhoneDescriptorAgain");
// Query manager.
descriptor.getQueryManager().checkCacheForDoesExist();
// Event manager.
// Query keys.
descriptor.addDirectQueryKey("id", "EMP_ID");
// Mappings.
DirectToFieldMapping typeMapping = new DirectToFieldMapping();
typeMapping.setAttributeName("type");
typeMapping.setFieldName("PHONE.TYPE");
descriptor.addMapping(typeMapping);
descriptor.applyAmendmentMethod();
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class GetMethodReturnTypeNotValidTest 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;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class IllegalAccessWhileGettingValueThruInstanceVariableAccessorTest 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");
// Query manager.
descriptor.getQueryManager().checkCacheForDoesExist();
// Named Queries
// Event manager.
// Mappings.
DirectToFieldMapping p_idMapping = new DirectToFieldMapping();
p_idMapping.setAttributeName("id");
p_idMapping.setFieldName("EMPLOYEE.EMP_ID");
descriptor.addMapping(p_idMapping);
DirectToFieldMapping p_nameMapping = new DirectToFieldMapping();
p_nameMapping.setAttributeName("illegalAccess");
p_nameMapping.setFieldName("EMPLOYEE.F_NAME");
p_nameMapping.setSetMethodName("setIllegalAccess");
p_nameMapping.setGetMethodName("getIllegalAccess");
descriptor.addMapping(p_nameMapping);
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class IllegalArgumentWhileGettingValueThruMethodAccessorTest method descriptor.
public RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(org.eclipse.persistence.testing.tests.validation.PersonMethodAccess.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");
// Query manager.
descriptor.getQueryManager().checkCacheForDoesExist();
// Named Queries
// Event manager.
// Mappings.
DirectToFieldMapping p_idMapping = new DirectToFieldMapping();
p_idMapping.setAttributeName("p_id");
p_idMapping.setFieldName("EMPLOYEE.EMP_ID");
p_idMapping.setGetMethodName("getId");
p_idMapping.setSetMethodName("setId");
p_idMapping.getAttributeAccessor().initializeAttributes(PersonMethodAccess.class);
descriptor.addMapping(p_idMapping);
DirectToFieldMapping p_nameMapping = new DirectToFieldMapping();
p_nameMapping.setAttributeName("p_name");
p_nameMapping.setFieldName("EMPLOYEE.F_NAME");
p_nameMapping.setGetMethodName("getName");
p_nameMapping.setSetMethodName("setName");
p_nameMapping.getAttributeAccessor().initializeAttributes(PersonMethodAccess.class);
descriptor.addMapping(p_nameMapping);
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class IllegalArgumentWhileInvokingAttributeMethodTest method setup.
@Override
protected void setup() {
descriptor = new RelationalDescriptor();
descriptor.setJavaClass(IllegalArgumentWhileInvokingAttributeMethodTest.class);
descriptor.addTableName("EMPLOYEE");
mapping = new TransformationMapping();
mapping.setAttributeName("normalHours");
mapping.setAttributeTransformation("invalidMethod");
descriptor.addMapping(mapping);
mapping.initialize((AbstractSession) getSession());
row = new DatabaseRecord();
expectedException = DescriptorException.illegalArgumentWhileInvokingAttributeMethod(mapping, new Exception());
}
Aggregations