Search in sources :

Example 36 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class RelationshipsProject method buildFieldLocationDescriptor.

public RelationalDescriptor buildFieldLocationDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldLocation.class);
    descriptor.addTableName("FIELDLOCATION");
    descriptor.addPrimaryKeyFieldName("FIELDLOCATION.ID");
    // RelationalDescriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("FIELDLOCATION.ID");
    descriptor.setSequenceNumberName("REL_FIELD_LOC_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("FIELDLOCATION.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping cityMapping = new DirectToFieldMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setFieldName("FIELDLOCATION.CITY");
    descriptor.addMapping(cityMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 37 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class RelationshipsProject method buildFieldOfficeDescriptor.

public RelationalDescriptor buildFieldOfficeDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice.class);
    descriptor.addTableName("FIELDOFFICE");
    descriptor.addPrimaryKeyFieldName("FIELDOFFICE.ID");
    // RelationalDescriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("FIELDOFFICE.ID");
    descriptor.setSequenceNumberName("REL_FIELD_OFFICE_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("FIELDOFFICE.ID");
    descriptor.addMapping(idMapping);
    OneToOneMapping locationMapping = new OneToOneMapping();
    locationMapping.setAttributeName("location");
    locationMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldLocation.class);
    locationMapping.useBasicIndirection();
    locationMapping.addForeignKeyFieldName("FIELDOFFICE.LOCATION_ID", "FIELDLOCATION.ID");
    descriptor.addMapping(locationMapping);
    OneToOneMapping managerMapping = new OneToOneMapping();
    managerMapping.setAttributeName("manager");
    managerMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldManager.class);
    managerMapping.useBasicIndirection();
    managerMapping.addForeignKeyFieldName("FIELDOFFICE.MANAGER_ID", "FIELDMANAGER.ID");
    managerMapping.setRelationshipPartnerAttributeName("office");
    descriptor.addMapping(managerMapping);
    OneToManyMapping salespeopleMapping = new OneToManyMapping();
    salespeopleMapping.setAttributeName("salespeople");
    salespeopleMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson.class);
    salespeopleMapping.useTransparentCollection();
    salespeopleMapping.useCollectionClass(org.eclipse.persistence.indirection.IndirectSet.class);
    salespeopleMapping.addTargetForeignKeyFieldName("SALESPERSON.OFFICE_ID", "FIELDOFFICE.ID");
    salespeopleMapping.setRelationshipPartnerAttributeName("fieldOffice");
    descriptor.addMapping(salespeopleMapping);
    OneToManyMapping resourceMapping = new OneToManyMapping();
    resourceMapping.setAttributeName("resources");
    resourceMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.Resource.class);
    resourceMapping.dontUseIndirection();
    resourceMapping.useCollectionClass(org.eclipse.persistence.indirection.IndirectList.class);
    resourceMapping.addTargetForeignKeyFieldName("REL_RESOURCE.OFFICE_ID", "FIELDOFFICE.ID");
    resourceMapping.setRelationshipPartnerAttributeName("deptno");
    descriptor.addMapping(resourceMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 38 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class RelationshipsProject method buildCustomerDescriptor.

public RelationalDescriptor buildCustomerDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(Customer.class);
    descriptor.addTableName("REL_CUSTOMER");
    descriptor.addPrimaryKeyFieldName("REL_CUSTOMER.ID");
    // RelationalDescriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("REL_CUSTOMER.ID");
    descriptor.setSequenceNumberName("REL_CUSTOMER_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("REL_CUSTOMER.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping nameMapping = new DirectToFieldMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setFieldName("REL_CUSTOMER.NAME");
    descriptor.addMapping(nameMapping);
    ManyToManyMapping salespeopleMapping = new ManyToManyMapping();
    salespeopleMapping.setAttributeName("salespeople");
    salespeopleMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.SalesPerson.class);
    salespeopleMapping.useTransparentCollection();
    salespeopleMapping.useCollectionClass(org.eclipse.persistence.indirection.IndirectSet.class);
    salespeopleMapping.readOnly();
    salespeopleMapping.setRelationTableName("SALES_CUST");
    salespeopleMapping.addSourceRelationKeyFieldName("SALES_CUST.CUST_ID", "REL_CUSTOMER.ID");
    salespeopleMapping.addTargetRelationKeyFieldName("SALES_CUST.SALES_ID", "SALESPERSON.ID");
    salespeopleMapping.setRelationshipPartnerAttributeName("customers");
    descriptor.addMapping(salespeopleMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 39 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class RelationshipsProject method buildEmpDescriptor.

public RelationalDescriptor buildEmpDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.relationshipmaintenance.Emp.class);
    descriptor.addTableName("REL_EMP");
    descriptor.addPrimaryKeyFieldName("REL_EMP.ID");
    // RelationalDescriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(10);
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("empno");
    idMapping.setFieldName("REL_EMP.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping nameMapping = new DirectToFieldMapping();
    nameMapping.setAttributeName("ename");
    nameMapping.setFieldName("REL_EMP.NAME");
    descriptor.addMapping(nameMapping);
    OneToOneMapping deptMapping = new OneToOneMapping();
    deptMapping.setAttributeName("deptno");
    deptMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.Dept.class);
    deptMapping.useBasicIndirection();
    deptMapping.addForeignKeyFieldName("REL_EMP.DEPTNO", "REL_DEPT.DEPTNO");
    deptMapping.setRelationshipPartnerAttributeName("empCollection");
    descriptor.addMapping(deptMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 40 with RelationalDescriptor

use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.

the class RelationshipsProject method buildResourceDescriptor.

public RelationalDescriptor buildResourceDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.relationshipmaintenance.Resource.class);
    descriptor.addTableName("REL_RESOURCE");
    descriptor.addPrimaryKeyFieldName("REL_RESOURCE.ID");
    // RelationalDescriptor properties.
    descriptor.useFullIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("REL_RESOURCE.ID");
    descriptor.setSequenceNumberName("REL_RESOURCE_SEQ");
    // Query manager.
    descriptor.getQueryManager().checkDatabaseForDoesExist();
    // Event manager.
    // Mappings.
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("REL_RESOURCE.ID");
    descriptor.addMapping(idMapping);
    DirectToFieldMapping nameMapping = new DirectToFieldMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setFieldName("REL_RESOURCE.NAME");
    descriptor.addMapping(nameMapping);
    OneToOneMapping officeMapping = new OneToOneMapping();
    officeMapping.setAttributeName("office");
    officeMapping.setReferenceClass(org.eclipse.persistence.testing.models.relationshipmaintenance.FieldOffice.class);
    officeMapping.useBasicIndirection();
    officeMapping.addForeignKeyFieldName("REL_RESOURCE.OFFICE_ID", "FIELDOFFICE.ID");
    descriptor.addMapping(officeMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

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