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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations