use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class MappingProject method buildShipmentDescriptor.
protected void buildShipmentDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// SECTION: DESCRIPTOR
descriptor.setJavaClass(Shipment.class);
Vector vector = new Vector();
vector.addElement("MAP_SHIP");
descriptor.setTableNames(vector);
descriptor.addPrimaryKeyFieldName("MAP_SHIP.SP_TS");
descriptor.addPrimaryKeyFieldName("MAP_SHIP.SP_TSMIL");
// SECTION: EVENT MANAGER
descriptor.getEventManager().setPreInsertSelector("prepareForInsert");
// SECTION: PROPERTIES
// SECTION: COPY POLICY
descriptor.createCopyPolicy("constructor");
// SECTION: INSTANTIATION POLICY
descriptor.createInstantiationPolicy("constructor");
// SECTION: DIRECTTOFIELDMAPPING
DirectToFieldMapping directtofieldmapping = new DirectToFieldMapping();
directtofieldmapping.setAttributeName("creationTimestamp");
directtofieldmapping.setIsReadOnly(false);
directtofieldmapping.setFieldName("MAP_SHIP.SP_TS");
descriptor.addMapping(directtofieldmapping);
// SECTION: DIRECTTOFIELDMAPPING
DirectToFieldMapping directtofieldmapping1 = new DirectToFieldMapping();
directtofieldmapping1.setAttributeName("creationTimestampMillis");
directtofieldmapping1.setIsReadOnly(false);
directtofieldmapping1.setFieldName("MAP_SHIP.SP_TSMIL");
descriptor.addMapping(directtofieldmapping1);
// SECTION: DIRECTTOFIELDMAPPING
DirectToFieldMapping directtofieldmapping2 = new DirectToFieldMapping();
directtofieldmapping2.setAttributeName("quantityShipped");
directtofieldmapping2.setIsReadOnly(false);
directtofieldmapping2.setFieldName("MAP_SHIP.QUANTITY");
descriptor.addMapping(directtofieldmapping2);
// SECTION: DIRECTTOFIELDMAPPING
DirectToFieldMapping directtofieldmapping3 = new DirectToFieldMapping();
directtofieldmapping3.setAttributeName("shipMode");
directtofieldmapping3.setIsReadOnly(false);
directtofieldmapping3.setFieldName("MAP_SHIP.SHP_MODE");
descriptor.addMapping(directtofieldmapping3);
// SECTION: MANYTOMANYMAPPING
ManyToManyMapping manytomanymapping = new ManyToManyMapping();
manytomanymapping.setAttributeName("employees");
manytomanymapping.setIsReadOnly(true);
manytomanymapping.setUsesIndirection(false);
manytomanymapping.setReferenceClass(Employee.class);
manytomanymapping.setIsPrivateOwned(false);
manytomanymapping.setRelationTableName("MAP_EMSP");
manytomanymapping.addSourceRelationKeyFieldName("MAP_EMSP.SP_TSMIL", "MAP_SHIP.SP_TSMIL");
manytomanymapping.addSourceRelationKeyFieldName("MAP_EMSP.SP_TS", "MAP_SHIP.SP_TS");
manytomanymapping.addTargetRelationKeyFieldName("MAP_EMSP.EMP_LNAME", "MAP_EMP.LNAME");
manytomanymapping.addTargetRelationKeyFieldName("MAP_EMSP.EMP_FNAME", "MAP_EMP.FNAME");
descriptor.addMapping(manytomanymapping);
addDescriptor(descriptor);
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class Contact method descriptor.
public static RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
OneToOneMapping addressMapping = new OneToOneMapping();
OneToOneMapping employeeMapping = new OneToOneMapping();
/* First define the class, table and descriptor properties. */
descriptor.setJavaClass(Contact.class);
descriptor.setTableName("U_CON");
descriptor.setPrimaryKeyFieldName("ID");
descriptor.setSequenceNumberName("SEQ");
descriptor.setSequenceNumberFieldName("ID");
/* Next define the attribute mappings. */
descriptor.addDirectMapping("id", "ID");
descriptor.addDirectMapping("type", "TYPE");
addressMapping.setAttributeName("mailAddress");
addressMapping.setReferenceClass(MailAddress.class);
addressMapping.addForeignKeyFieldName("ADDRESS", "ID");
addressMapping.dontUseIndirection();
descriptor.addMapping(addressMapping);
employeeMapping.setAttributeName("person");
employeeMapping.setReferenceClass(Person.class);
employeeMapping.addForeignKeyFieldName("EMP_ID", "ID");
employeeMapping.dontUseIndirection();
descriptor.addMapping(employeeMapping);
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class ConcurrentPhoneNumber method descriptor.
public static RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
/* First define the class, table and descriptor properties. */
descriptor.setJavaClass(ConcurrentPhoneNumber.class);
descriptor.setTableName("CONCURRENT_PHONE");
descriptor.addPrimaryKeyFieldName("CONCURRENT_PHONE.EMP_ID");
descriptor.addPrimaryKeyFieldName("CONCURRENT_PHONE.TYPE");
/* Next define the attribute mappings. */
descriptor.addDirectMapping("type", "TYPE");
descriptor.addDirectMapping("areaCode", "AREA_CODE");
descriptor.addDirectMapping("number", "PHONE_NUM");
OneToOneMapping ownerMapping = new OneToOneMapping();
ownerMapping.setAttributeName("owner");
ownerMapping.setReferenceClass(ConcurrentPerson.class);
ownerMapping.setGetMethodName("getOwnerVH");
ownerMapping.setSetMethodName("setOwnerVH");
ownerMapping.useBasicIndirection();
ownerMapping.addForeignKeyFieldName("CONCURRENT_PHONE.EMP_ID", "CONCURRENT_EMP.ID");
descriptor.addMapping(ownerMapping);
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class ConcurrentProject method descriptor.
public static RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
/* First define the class, table and descriptor properties. */
descriptor.setJavaClass(ConcurrentProject.class);
descriptor.setTableName("CONCURRENT_PROJECT");
descriptor.setPrimaryKeyFieldName("ID");
descriptor.setSequenceNumberName("SEQ");
descriptor.setSequenceNumberFieldName("ID");
/* Next define the attribute mappings. */
descriptor.addDirectMapping("id", "ID");
DirectToFieldMapping nameMapping = new DirectToFieldMapping();
nameMapping.setAttributeName("name");
nameMapping.setFieldName("NAME");
nameMapping.setGetMethodName("getName");
nameMapping.setSetMethodName("setName");
descriptor.addMapping(nameMapping);
// Inheritance Properties.
descriptor.getInheritancePolicy().setClassIndicatorFieldName("CONCURRENT_PROJECT.DISCRIM");
descriptor.getInheritancePolicy().addClassIndicator(ConcurrentProject.class, "P");
descriptor.getInheritancePolicy().addClassIndicator(ConcurrentLargeProject.class, "L");
return descriptor;
}
use of org.eclipse.persistence.descriptors.RelationalDescriptor in project eclipselink by eclipse-ee4j.
the class EmailAccount method descriptor.
public static RelationalDescriptor descriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
/* First define the class, table and descriptor properties. */
descriptor.setJavaClass(EmailAccount.class);
descriptor.setTableName("EMAILACC");
descriptor.setPrimaryKeyFieldName("ID");
descriptor.setSequenceNumberName("SEQ");
descriptor.setSequenceNumberFieldName("ID");
/* Next define the attribute mappings. */
descriptor.addDirectMapping("id", "ID");
descriptor.addDirectMapping("emailAddress", "EMAILADD");
descriptor.addDirectMapping("owner", "ACC_OWNER");
descriptor.addDirectMapping("hostName", "HOSTNAME");
return descriptor;
}
Aggregations