Search in sources :

Example 41 with RelationalDescriptor

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

the class Actor method descriptor.

// Actor descriptor
public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.readonly.Actor.class);
    descriptor.setTableName("RO_ACTOR");
    descriptor.setPrimaryKeyFieldName("ACT_ID");
    descriptor.setSequenceNumberName("SEQ");
    descriptor.setSequenceNumberFieldName("ACT_ID");
    descriptor.addDirectMapping("id", "ACT_ID");
    descriptor.addDirectMapping("name", "ACT_NAME");
    descriptor.addDirectMapping("minimumSalary", "MIN_SAL");
    ManyToManyMapping moviesMapping = new ManyToManyMapping();
    moviesMapping.setAttributeName("movies");
    moviesMapping.setReferenceClass(Movie.class);
    moviesMapping.setRelationTableName("ACT_MOV");
    moviesMapping.setSourceRelationKeyFieldName("ACT_ID");
    moviesMapping.setTargetRelationKeyFieldName("MOV_ID");
    moviesMapping.dontUseIndirection();
    moviesMapping.readOnly();
    descriptor.addMapping(moviesMapping);
    // ManyToManyMapping: charities
    ManyToManyMapping charitiesMapping = new ManyToManyMapping();
    charitiesMapping.setAttributeName("charities");
    charitiesMapping.setReferenceClass(ReadOnlyCharity.class);
    charitiesMapping.setRelationTableName("ACT_CHA");
    charitiesMapping.setSourceRelationKeyFieldName("ACT_ID");
    charitiesMapping.setTargetRelationKeyFieldName("CHARITY_ID");
    charitiesMapping.dontUseIndirection();
    descriptor.addMapping(charitiesMapping);
    // OneToOneMapping: hollywoodAgent
    OneToOneMapping hollywoodAgentMapping = new OneToOneMapping();
    hollywoodAgentMapping.setAttributeName("hollywoodAgent");
    hollywoodAgentMapping.setReferenceClass(ReadOnlyHollywoodAgent.class);
    hollywoodAgentMapping.addForeignKeyFieldName("HOLLYWOODAGENT_ID", "HOLLYWOODAGENT_ID");
    hollywoodAgentMapping.dontUseIndirection();
    // hollywoodAgentMapping.readOnly();
    descriptor.addMapping(hollywoodAgentMapping);
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 42 with RelationalDescriptor

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

the class Charity method descriptor.

// Charity descriptor
public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.readonly.Charity.class);
    descriptor.setTableName("CHARITY");
    descriptor.addPrimaryKeyFieldName("CHARITY_ID");
    descriptor.setSequenceNumberName("CHARITY_SEQ");
    descriptor.setSequenceNumberFieldName("CHARITY_ID");
    descriptor.addDirectMapping("id", "CHARITY_ID");
    descriptor.addDirectMapping("name", "NAME");
    descriptor.addDirectMapping("donationsRaised", "DONATIONS_RAISED");
    return descriptor;
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 43 with RelationalDescriptor

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

the class IndirectContainerProject method buildOrderLineDescriptor.

/**
 * modifications are marked with "bjv"
 */
@Override
protected void buildOrderLineDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(orderLineClass());
    Vector vector = new Vector();
    vector.addElement("ORDLINE");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("ORDLINE.ID");
    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setSequenceNumberName("orderline");
    descriptor.setSequenceNumberFieldName("ID");
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    // SECTION: COPY POLICY
    descriptor.createCopyPolicy("constructor");
    // SECTION: INSTANTIATION POLICY
    descriptor.createInstantiationPolicy("constructor");
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setFieldName("ORDLINE.ID");
    descriptor.addMapping(directtofieldmapping);
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping1 = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping1.setAttributeName("itemName");
    directtofieldmapping1.setIsReadOnly(false);
    directtofieldmapping1.setFieldName("ORDLINE.ITEM_NAME");
    descriptor.addMapping(directtofieldmapping1);
    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping2 = new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping2.setAttributeName("quantity");
    directtofieldmapping2.setIsReadOnly(false);
    directtofieldmapping2.setFieldName("ORDLINE.QUANTITY");
    descriptor.addMapping(directtofieldmapping2);
    // SECTION: ONETOONEMAPPING
    org.eclipse.persistence.mappings.OneToOneMapping onetoonemapping = new org.eclipse.persistence.mappings.OneToOneMapping();
    onetoonemapping.setAttributeName("order");
    onetoonemapping.setIsReadOnly(false);
    onetoonemapping.setUsesIndirection(false);
    // bjv
    onetoonemapping.setReferenceClass(this.orderClass());
    onetoonemapping.setIsPrivateOwned(false);
    onetoonemapping.addForeignKeyFieldName("ORDLINE.ORDER_ID", "ORD.ID");
    descriptor.addMapping(onetoonemapping);
    addDescriptor(descriptor);
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 44 with RelationalDescriptor

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

the class ReadOnlyProject method buildCharityDescriptor.

protected void buildCharityDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(Charity.class);
    descriptor.setTableName("CHARITY");
    descriptor.addPrimaryKeyFieldName("CHARITY_ID");
    descriptor.setSequenceNumberName("CHARITY_SEQ");
    descriptor.setSequenceNumberFieldName("CHARITY_ID");
    descriptor.addDirectMapping("id", "CHARITY_ID");
    descriptor.addDirectMapping("name", "NAME");
    descriptor.addDirectMapping("donationsRaised", "DONATIONS_RAISED");
    addDescriptor(descriptor);
}
Also used : RelationalDescriptor(org.eclipse.persistence.descriptors.RelationalDescriptor)

Example 45 with RelationalDescriptor

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

the class ReadOnlyProject method buildReadOnlyHollywoodAgentDescriptor.

protected void buildReadOnlyHollywoodAgentDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(ReadOnlyHollywoodAgent.class);
    descriptor.setTableName("HOLLYWOODAGENT");
    descriptor.addPrimaryKeyFieldName("HOLLYWOODAGENT_ID");
    descriptor.setSequenceNumberName("HOLLYWOODAGENT_SEQ");
    descriptor.setSequenceNumberFieldName("HOLLYWOODAGENT_ID");
    descriptor.addDirectMapping("id", "HOLLYWOODAGENT_ID");
    descriptor.addDirectMapping("name", "NAME");
    addDescriptor(descriptor);
    addDefaultReadOnlyClass(ReadOnlyHollywoodAgent.class);
}
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