use of org.eclipse.persistence.mappings.TransformationMapping in project eclipselink by eclipse-ee4j.
the class AggregateProject method amendJobDescriptor.
/**
* The field types must be set in an amendment as the XML format does not support types.
*/
public static void amendJobDescriptor(ClassDescriptor descriptor) {
TransformationMapping transformationmapping = (TransformationMapping) descriptor.getMappingForAttributeName("normalHours");
transformationmapping.getFieldTransformations().clear();
DatabaseField field = new DatabaseField("WORKER.END_TIME");
field.setType(java.sql.Time.class);
transformationmapping.addFieldTransformation(field, "getEndTime");
field = new DatabaseField("WORKER.START_TIME");
field.setType(java.sql.Time.class);
transformationmapping.addFieldTransformation(field, "getStartTime");
}
use of org.eclipse.persistence.mappings.TransformationMapping 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());
}
use of org.eclipse.persistence.mappings.TransformationMapping in project eclipselink by eclipse-ee4j.
the class SecurityWhileConvertingToMethodTest method setup.
@Override
protected void setup() {
super.setup();
expectedException = DescriptorException.securityWhileConvertingToMethod("getStartTime", mapping, new Exception());
mapping = new TransformationMapping();
mapping.setAttributeName("normalHours");
mapping.setAttributeTransformation("buildNormalHours");
mapping.addFieldTransformation("EMPLOYEE.START_TIME", "getStartTime");
mapping.addFieldTransformation("EMPLOYEE.END_TIME", "getEndTime");
// the following three lines ensure that the mapping is not isWriteOnly();
mapping.setAttributeName(null);
mapping.getAttributeAccessor().setAttributeName(null);
mapping.setAttributeTransformation(null);
mapping.setDescriptor(getTestDescriptor());
}
use of org.eclipse.persistence.mappings.TransformationMapping in project eclipselink by eclipse-ee4j.
the class SecurityOnInitializingAttributeMethodTest method setup.
@Override
protected void setup() {
super.setup();
expectedException = DescriptorException.securityOnInitializingAttributeMethod("buildNormalHours", mapping, new Exception());
mapping = new TransformationMapping();
mapping.setAttributeName("normalHours");
//
mapping.setAttributeTransformation("buildNormalHours");
//
mapping.addFieldTransformation("EMPLOYEE.START_TIME", "getStartTime");
//
mapping.addFieldTransformation("EMPLOYEE.END_TIME", "getEndTime");
mapping.setDescriptor(getTestDescriptor());
}
use of org.eclipse.persistence.mappings.TransformationMapping in project eclipselink by eclipse-ee4j.
the class TargetInvocationWhileInvokingAttributeMethodTest method setup.
@Override
protected void setup() {
descriptor = new RelationalDescriptor();
descriptor.setJavaClass(TargetInvocationWhileInvokingAttributeMethodTest.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.targetInvocationWhileInvokingAttributeMethod(mapping, new Exception());
}
Aggregations