Package org.eclipse.persistence.mappings

Examples of org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping


            // If we find a JoinColumn(s) annotations then process a
            // uni-directional one to many.
            if (!getJoinColumns().isEmpty()) {
                // Create a 1-M unidirectional mapping and process common collection mapping
                // metadata.
                UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
                process(mapping);
               
                // Process the JoinTable metadata.
                processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping);
               
                // Process properties
                processProperties(mapping);

                // Add the mapping to the descriptor.
                getDescriptor().addMapping(mapping);
            } else {
                // Create a M-M mapping and process common collection mapping
                // metadata.
                ManyToManyMapping mapping = new ManyToManyMapping();
                process(mapping);
               
                // Process the JoinTable metadata.
                processJoinTable(mapping);
               
                // Process properties
                processProperties(mapping);
   
                // Add the mapping to the descriptor.
                getDescriptor().addMapping(mapping);
            }
        } else {
            // Create a 1-M mapping and process common collection mapping
            // metadata.
            OneToManyMapping mapping = new OneToManyMapping();
            process(mapping);
           
            // Non-owning side, process the foreign keys from the owner.
            OneToOneMapping ownerMapping = null;
            if (getOwningMapping(getMappedBy()).isOneToOneMapping()){
                ownerMapping = (OneToOneMapping) getOwningMapping(getMappedBy());
            } else {
                // If improper mapping encountered, throw an exception.
                throw ValidationException.invalidMapping(getJavaClass(), getReferenceClass());
            }
               
            Map<DatabaseField, DatabaseField> keys = ownerMapping.getSourceToTargetKeyFields();
            for (DatabaseField fkField : keys.keySet()) {
                DatabaseField pkField = keys.get(fkField);
               
                // If we are within a table per class strategy we have to update
                // the primary key field to point to our own database table.
                // The extra table check is if the mapping is actually defined
                // on our java class (meaning we have the right table at this
                // point and can avoid the cloning)
                if (getDescriptor().usesTablePerClassInheritanceStrategy() && ! pkField.getTable().equals(getDescriptor().getPrimaryTable())) {
                    // We need to update the pk field to be to our table.
                    pkField = (DatabaseField) pkField.clone();
                    pkField.setTable(getDescriptor().getPrimaryTable());
                }
           
                mapping.addTargetForeignKeyField(fkField, pkField);
            }  
           
            // Process properties
            processProperties(mapping);
           
View Full Code Here


            // If we find a JoinColumn(s) annotations then process a
            // uni-directional one to many.
            if (!getJoinColumns().isEmpty()) {
                // Create a 1-M unidirectional mapping and process common collection mapping
                // metadata.
                UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
                process(mapping);
               
                // Process the JoinTable metadata.
                processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping);
               
                // Process properties
                processProperties(mapping);

                // Add the mapping to the descriptor.
                getDescriptor().addMapping(mapping);
            } else {
                // Create a M-M mapping and process common collection mapping
                // metadata.
                ManyToManyMapping mapping = new ManyToManyMapping();
                process(mapping);
               
                // Process the JoinTable metadata.
                processJoinTable(mapping);
               
                // Process properties
                processProperties(mapping);
   
                // Add the mapping to the descriptor.
                getDescriptor().addMapping(mapping);
            }
        } else {
            // Create a 1-M mapping and process common collection mapping
            // metadata.
            OneToManyMapping mapping = new OneToManyMapping();
            process(mapping);
           
            // Non-owning side, process the foreign keys from the owner.
            OneToOneMapping ownerMapping = null;
            if (getOwningMapping(getMappedBy()).isOneToOneMapping()){
                ownerMapping = (OneToOneMapping) getOwningMapping(getMappedBy());
            } else {
                // If improper mapping encountered, throw an exception.
                throw ValidationException.invalidMapping(getJavaClass(), getReferenceClass());
            }
               
            Map<DatabaseField, DatabaseField> keys = ownerMapping.getSourceToTargetKeyFields();
            for (DatabaseField fkField : keys.keySet()) {
                DatabaseField pkField = keys.get(fkField);
               
                // If we are within a table per class strategy we have to update
                // the primary key field to point to our own database table.
                // The extra table check is if the mapping is actually defined
                // on our java class (meaning we have the right table at this
                // point and can avoid the cloning)
                if (getDescriptor().usesTablePerClassInheritanceStrategy() && ! pkField.getTable().equals(getDescriptor().getPrimaryTable())) {
                    // We need to update the pk field to be to our table.
                    pkField = (DatabaseField) pkField.clone();
                    pkField.setTable(getDescriptor().getPrimaryTable());
                }
           
                mapping.addTargetForeignKeyField(fkField, pkField);
            }  
           
            // Process properties
            processProperties(mapping);
           
View Full Code Here

     */
    @Override
    protected void processAssociationOverride(AssociationOverrideMetadata associationOverride, EmbeddableMapping embeddableMapping, MetadataDescriptor owningDescriptor) {
        if (getMapping().isUnidirectionalOneToManyMapping()) {
            // Create an override mapping and process the join columns to it.
            UnidirectionalOneToManyMapping overrideMapping = new UnidirectionalOneToManyMapping();
            overrideMapping.setAttributeName(getAttributeName());
            processUnidirectionalOneToManyTargetForeignKeyRelationship(overrideMapping, associationOverride.getJoinColumns(), owningDescriptor);
       
            // The override mapping will have the correct source, sourceRelation,
            // target and targetRelation keys. Along with the correct relation table.
            embeddableMapping.addOverrideUnidirectionalOneToManyMapping(overrideMapping);
View Full Code Here

     * join columns were specified and no mapped by value.
     */
    protected void processUnidirectionalOneToManyMapping() {
        // Create a 1-M unidirectional mapping and process common collection
        // mapping metadata first followed by specific metadata.
        UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
        process(mapping);
       
        // Process the JoinColumn metadata.
        processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping, getJoinColumns(getJoinColumns(), getOwningDescriptor()), getOwningDescriptor());
    }
View Full Code Here

     */
    @Override
    protected void processAssociationOverride(AssociationOverrideMetadata associationOverride, EmbeddableMapping embeddableMapping, MetadataDescriptor owningDescriptor) {
        if (getMapping().isUnidirectionalOneToManyMapping()) {
            // Create an override mapping and process the join columns to it.
            UnidirectionalOneToManyMapping overrideMapping = new UnidirectionalOneToManyMapping();
            overrideMapping.setAttributeName(getAttributeName());
            processUnidirectionalOneToManyTargetForeignKeyRelationship(overrideMapping, associationOverride.getJoinColumns(), owningDescriptor);
       
            // The override mapping will have the correct source, sourceRelation,
            // target and targetRelation keys. Along with the correct relation table.
            embeddableMapping.addOverrideUnidirectionalOneToManyMapping(overrideMapping);
View Full Code Here

     * join columns were specified and no mapped by value.
     */
    protected void processUnidirectionalOneToManyMapping() {
        // Create a 1-M unidirectional mapping and process common collection
        // mapping metadata first followed by specific metadata.
        UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
        process(mapping);
       
        // Process the JoinColumn metadata.
        processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping, getJoinColumns(getJoinColumns(), getOwningDescriptor()), getOwningDescriptor());
    }
View Full Code Here

     * join columns were specified and no mapped by value.
     */
    protected void processUnidirectionalOneToManyMapping() {
        // Create a 1-M unidirectional mapping and process common collection
        // mapping metadata first followed by specific metadata.
        UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
        process(mapping);
       
        // Process the JoinColumn metadata.
        processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping, getJoinColumns(getJoinColumns(), getOwningDescriptor()), getOwningDescriptor());
    }
View Full Code Here

     */
    @Override
    protected void processAssociationOverride(AssociationOverrideMetadata associationOverride, EmbeddableMapping embeddableMapping, MetadataDescriptor owningDescriptor) {
        if (getMapping().isUnidirectionalOneToManyMapping()) {
            // Create an override mapping and process the join columns to it.
            UnidirectionalOneToManyMapping overrideMapping = new UnidirectionalOneToManyMapping();
            overrideMapping.setAttributeName(getAttributeName());
            processUnidirectionalOneToManyTargetForeignKeyRelationship(overrideMapping, associationOverride.getJoinColumns(), owningDescriptor);
       
            // The override mapping will have the correct source, sourceRelation,
            // target and targetRelation keys. Along with the correct relation table.
            embeddableMapping.addOverrideUnidirectionalOneToManyMapping(overrideMapping);
View Full Code Here

     */
    @Override
    protected void processAssociationOverride(AssociationOverrideMetadata associationOverride, EmbeddableMapping embeddableMapping, MetadataDescriptor owningDescriptor) {
        if (getMapping().isUnidirectionalOneToManyMapping()) {
            // Create an override mapping and process the join columns to it.
            UnidirectionalOneToManyMapping overrideMapping = new UnidirectionalOneToManyMapping();
            overrideMapping.setAttributeName(getAttributeName());
            processUnidirectionalOneToManyTargetForeignKeyRelationship(overrideMapping, associationOverride.getJoinColumns(), owningDescriptor);
       
            // The override mapping will have the correct source, sourceRelation,
            // target and targetRelation keys. Along with the correct relation table.
            embeddableMapping.addOverrideUnidirectionalOneToManyMapping(overrideMapping);
View Full Code Here

     * join columns were specified and no mapped by value.
     */
    protected void processUnidirectionalOneToManyMapping() {
        // Create a 1-M unidirectional mapping and process common collection
        // mapping metadata first followed by specific metadata.
        UnidirectionalOneToManyMapping mapping = new UnidirectionalOneToManyMapping();
        process(mapping);
       
        // Process the JoinColumn metadata.
        processUnidirectionalOneToManyTargetForeignKeyRelationship(mapping, getJoinColumns(getJoinColumns(), getReferenceDescriptor()), getOwningDescriptor());
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.