Examples of OneToOneMapping


Examples of org.eclipse.persistence.mappings.OneToOneMapping

                        overrideField.setTable(getReferenceDatabaseTable());
                    }
                   
                    addFieldNameTranslation(embeddableMapping, overrideName, overrideField, mappingAccessor);
                } else if (mapping.isOneToOneMapping()) {
                    OneToOneMapping oneToOneMapping = (OneToOneMapping) mapping;
                   
                    if (oneToOneMapping.isForeignKeyRelationship()) {
                        AssociationOverrideMetadata associationOverride = associationOverrides.get(overrideName);
                       
                        if (associationOverride == null) {
                            for (DatabaseField fkField : oneToOneMapping.getForeignKeyFields()) {
                                DatabaseField collectionTableField = fkField.clone();
                                collectionTableField.setTable(getReferenceDatabaseTable());
                                embeddableMapping.addFieldTranslation(collectionTableField, fkField.getName());
                            }
                        } else {
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

    /**
     * INTERNAL:
     * Initialize a OneToOneMapping.
     */
    protected OneToOneMapping initOneToOneMapping() {
        OneToOneMapping mapping = new OneToOneMapping();
        mapping.setIsOneToOneRelationship(true);
        processRelationshipMapping(mapping);
       
        mapping.setIsOptional(isOptional());
        mapping.setDerivesId(derivesId());
       
        // Process the indirection.
        processIndirection(mapping);
       
        // Process a @ReturnInsert and @ReturnUpdate (to log a warning message)
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

    @Override
    public void process() {
        super.process();
       
        // Initialize our mapping now with what we found.
        OneToOneMapping mapping = initOneToOneMapping();
       
        if (hasMappedBy()) {
            // Non-owning side, process the foreign keys from the owner.
            DatabaseMapping owningMapping = getOwningMappingAccessor();
            if (owningMapping.isOneToOneMapping()){
                OneToOneMapping ownerMapping = (OneToOneMapping) owningMapping;
               
                // If the owner uses a relation table, we need to map the keys
                // as we would for a many-to-many mapping.
                if (ownerMapping.hasRelationTableMechanism()) {
                    // Put a relation table mechanism on our mapping.
                    mapping.setRelationTableMechanism(new RelationTableMechanism());
                    processMappedByRelationTable(ownerMapping.getRelationTableMechanism(), mapping.getRelationTableMechanism());
                } else {
                    Map<DatabaseField, DatabaseField> targetToSourceKeyFields;
                    Map<DatabaseField, DatabaseField> sourceToTargetKeyFields;
                   
                    // If we are within a table per class strategy we have to update
                    // the primary key field to point to our own database table.
                    if (getDescriptor().usesTablePerClassInheritanceStrategy()) {
                        targetToSourceKeyFields = new HashMap<DatabaseField, DatabaseField>();
                        sourceToTargetKeyFields = new HashMap<DatabaseField, DatabaseField>();
                       
                        for (DatabaseField fkField : ownerMapping.getSourceToTargetKeyFields().keySet()) {
                            // We need to update the pk field to be to our table.
                            DatabaseField pkField = ownerMapping.getSourceToTargetKeyFields().get(fkField).clone();
                            pkField.setTable(getDescriptor().getPrimaryTable());
                            sourceToTargetKeyFields.put(fkField, pkField);
                            targetToSourceKeyFields.put(pkField, fkField);
                        }
                    } else {
                        targetToSourceKeyFields = ownerMapping.getTargetToSourceKeyFields();
                        sourceToTargetKeyFields = ownerMapping.getSourceToTargetKeyFields();
                    }
                   
                    mapping.setSourceToTargetKeyFields(targetToSourceKeyFields);
                    mapping.setTargetToSourceKeyFields(sourceToTargetKeyFields);
                }
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

     */
    protected OneToOneMapping processEntityMapKeyClass(MappedKeyMapAccessor mappedKeyMapAccessor) {
        String mapKeyClassName = mappedKeyMapAccessor.getMapKeyClass().getName();
       
        // Create the one to one map key mapping.
        OneToOneMapping keyMapping = new OneToOneMapping();
        keyMapping.setReferenceClassName(mapKeyClassName);
        keyMapping.dontUseIndirection();
        keyMapping.setDescriptor(getDescriptor().getClassDescriptor());
       
        // Process the map key join columns.
        EntityAccessor mapKeyAccessor = getProject().getEntityAccessor(mapKeyClassName);
        MetadataDescriptor mapKeyClassDescriptor = mapKeyAccessor.getDescriptor();
       
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

     */
    protected void processOneToManyMapping() {
       // Non-owning side, process the foreign keys from the owner.
       DatabaseMapping owningMapping = getOwningMappingAccessor();
       if (owningMapping.isOneToOneMapping()){
           OneToOneMapping ownerMapping = (OneToOneMapping) owningMapping;
          
           // If the owner uses a relation table mechanism we must map a M-M.
           if (ownerMapping.hasRelationTableMechanism()) {
              ManyToManyMapping mapping = new ManyToManyMapping();
              // Process the common collection mapping.
              process(mapping);
              // Process the mapped by relation table metadata.
              processMappedByRelationTable(ownerMapping.getRelationTableMechanism(), mapping.getRelationTableMechanism());
              // Set the mapping to read only
              mapping.setIsReadOnly(true);
           } else {
               // Create a 1-M mapping and process common collection mapping
               // metadata first followed by specific metadata.
              OneToManyMapping mapping = new OneToManyMapping();
              process(mapping);
             
               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.
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToOneMapping mapping = (OneToOneMapping)object;
                List associations = (List)value;
                mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1));
                mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue());
                    mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

        // first followed by specific 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.
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

    /**
     * INTERNAL:
     * Initialize a OneToOneMapping.
     */
    protected OneToOneMapping initOneToOneMapping() {
        OneToOneMapping mapping = new OneToOneMapping();
        mapping.setIsReadOnly(false);
        mapping.setJoinFetch(getMappingJoinFetchType(getJoinFetch()));
        mapping.setIsOptional(isOptional());
        mapping.setAttributeName(getAttributeName());
        mapping.setReferenceClassName(getReferenceClassName());
        mapping.setIsDerivedIdMapping(isDerivedId());
       
        // Process the orphanRemoval or PrivateOwned
        processOrphanRemoval(mapping);
       
        // Process the indirection.
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

     * INTERNAL:
     * Process a many to one setting into an EclipseLink OneToOneMapping.
     */
    public void process() {
        // Initialize our mapping now with what we found.
        OneToOneMapping mapping = initOneToOneMapping();
        setMapping(mapping);
       
        if (hasMappedById()) {
            // Mapping is mapped by id.
            processMappedByIdKeys(mapping);
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToOneMapping

    public OneToOneMapping addOneToOneMapping(String name, DynamicType refType, String... fkFieldNames) {
        if (fkFieldNames == null || refType.getDescriptor().getPrimaryKeyFields().size() != fkFieldNames.length) {
            throw new IllegalArgumentException("Invalid FK field names: " + fkFieldNames + " for target: " + refType);
        }

        OneToOneMapping mapping = new OneToOneMapping();
        mapping.setAttributeName(name);
        mapping.setReferenceClass(refType.getJavaClass());

        for (int index = 0; index < fkFieldNames.length; index++) {
            String targetField = refType.getDescriptor().getPrimaryKeyFields().get(index).getName();
            mapping.addForeignKeyFieldName(fkFieldNames[index], targetField);
        }

        return (OneToOneMapping) addMapping(mapping);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.