Search in sources :

Example 56 with RelationalDescriptor

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;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 57 with RelationalDescriptor

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;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) OneToManyMapping(org.eclipse.persistence.mappings.OneToManyMapping)

Example 58 with RelationalDescriptor

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;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 59 with RelationalDescriptor

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;
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 60 with RelationalDescriptor

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());
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) TransformationMapping(org.eclipse.persistence.mappings.TransformationMapping) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException) DescriptorException(org.eclipse.persistence.exceptions.DescriptorException)

Aggregations

RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)306 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)122 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)43 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)26 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)19 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)18 Vector (java.util.Vector)17 TransparentIndirectionPolicy (org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy)15 MappedKeyMapContainerPolicy (org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy)15 TransformationMapping (org.eclipse.persistence.mappings.TransformationMapping)13 IntegrityChecker (org.eclipse.persistence.exceptions.IntegrityChecker)12 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)10 java.util (java.util)9 AggregateObjectMapping (org.eclipse.persistence.mappings.AggregateObjectMapping)8 org.eclipse.persistence.mappings (org.eclipse.persistence.mappings)7 UnidirectionalOneToManyMapping (org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)6 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)6 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)6 DirectCollectionMapping (org.eclipse.persistence.mappings.DirectCollectionMapping)5 DirectMapMapping (org.eclipse.persistence.mappings.DirectMapMapping)4