Search in sources :

Example 11 with RelationalDescriptor

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

Example 12 with RelationalDescriptor

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

Example 13 with RelationalDescriptor

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

Example 14 with RelationalDescriptor

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

Example 15 with RelationalDescriptor

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