Examples of OneToManyMapping


Examples of org.eclipse.persistence.mappings.OneToManyMapping

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

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

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

        mapping.useTransparentList();

        return (OneToManyMapping) addMapping(mapping);
    }
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToManyMapping mapping = (OneToManyMapping)object;
                List associations = (List)value;
                mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
                    mapping.getTargetForeignKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

              // 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.
                   // 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 = pkField.clone();
                       pkField.setTable(getDescriptor().getPrimaryTable());
                   }
               
                   mapping.addTargetForeignKeyField(fkField, pkField);
               }
           }
       } else {
           // If improper mapping encountered, throw an exception.
           throw ValidationException.invalidMapping(getJavaClass(), getReferenceClass());
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToManyMapping mapping = (OneToManyMapping)object;
                List associations = (List)value;
                mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
                    mapping.getTargetForeignKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

     * Process an one to many mapping for this accessor.
     */
    protected void processOneToManyMapping() {
        // Create a 1-M mapping and process common collection mapping metadata
        // 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.
           // 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);
       }
    }
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

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

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

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

        mapping.useTransparentList();

        return (OneToManyMapping) addMapping(mapping);
    }
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

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

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

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

        mapping.useTransparentList();

        return (OneToManyMapping) addMapping(mapping);
    }
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

              // 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.
                   // 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 = pkField.clone();
                       pkField.setTable(getDescriptor().getPrimaryTable());
                   }
               
                   mapping.addTargetForeignKeyField(fkField, pkField);
               }
           }
       } else {
           // If improper mapping encountered, throw an exception.
           throw ValidationException.invalidMapping(getJavaClass(), getReferenceClass());
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToManyMapping mapping = (OneToManyMapping)object;
                List associations = (List)value;
                mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
                    mapping.getTargetForeignKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
View Full Code Here

Examples of org.eclipse.persistence.mappings.OneToManyMapping

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

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

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

        mapping.useTransparentList();

        return (OneToManyMapping) 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.