/** * PUBLIC: * Set the source key field names associated with the mapping. * These must be in-order with the targetForeignKeyFieldNames. */ public void setSourceKeyFieldNames(Vector fieldNames) { Vector fields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(fieldNames.size()); for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements();) { fields.addElement(new DatabaseField((String)fieldNamesEnum.nextElement())); } setSourceKeyFields(fields); }
/** * PUBLIC: * Set the source key field names associated with the mapping. * These must be in-order with the targetForeignKeyFieldNames. */ public void setSourceKeyFieldNames(Vector fieldNames) { Vector fields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(fieldNames.size()); for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements();) { fields.addElement(new DatabaseField((String)fieldNamesEnum.nextElement())); } setSourceKeyFields(fields); }
/** * PUBLIC: * Set the source key field names associated with the mapping. * These must be in-order with the targetForeignKeyFieldNames. */ public void setSourceKeyFieldNames(Vector fieldNames) { Vector fields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(fieldNames.size()); for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements();) { fields.addElement(new DatabaseField((String)fieldNamesEnum.nextElement())); } setSourceKeyFields(fields); }
public void setAttributeValueInObject(Object object, Object value) { AggregateCollectionMapping mapping = (AggregateCollectionMapping)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()); } } });
public void setAttributeValueInObject(Object object, Object value) { AggregateCollectionMapping mapping = (AggregateCollectionMapping)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()); } } });
@Override public void setAttributeValueInObject(Object object, Object value) { AggregateCollectionMapping mapping = (AggregateCollectionMapping)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()); } } });
/** * INTERNAL: * The foreign keys and the primary key names are converted to DatabaseFields and stored. The source keys * are not specified by the user so primary keys are extracted from the reference descriptor. */ protected void initializeTargetForeignKeyToSourceKeysWithDefaults(AbstractSession session) throws DescriptorException { if (getTargetForeignKeyFields().isEmpty()) { throw DescriptorException.noTargetForeignKeysSpecified(this); } List<DatabaseField> sourceKeys = getDescriptor().getPrimaryKeyFields(); setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(sourceKeys)); for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { DatabaseField foreignKeyfield = getTargetForeignKeyFields().get(index); foreignKeyfield = getReferenceDescriptor().buildField(foreignKeyfield); getTargetForeignKeyFields().set(index, foreignKeyfield); } if (getTargetForeignKeyFields().size() != sourceKeys.size()) { throw DescriptorException.targetForeignKeysSizeMismatch(this); } for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { getTargetForeignKeyToSourceKeys().put(getTargetForeignKeyFields().get(index), sourceKeys.get(index)); } }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { AggregateCollectionMapping mappingObject = (AggregateCollectionMapping)super.clone(); mappingObject.setTargetForeignKeyToSourceKeys(new HashMap(getTargetForeignKeyToSourceKeys())); mappingObject.setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getSourceKeyFields())); mappingObject.setTargetForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getTargetForeignKeyFields())); mappingObject.aggregateToSourceFields = new HashMap(this.aggregateToSourceFields); mappingObject.nestedAggregateToSourceFields = new HashMap(this.nestedAggregateToSourceFields); if(updateListOrderFieldQuery != null) { mappingObject.updateListOrderFieldQuery = this.updateListOrderFieldQuery; } if(bulkUpdateListOrderFieldQuery != null) { mappingObject.bulkUpdateListOrderFieldQuery = this.bulkUpdateListOrderFieldQuery; } if(pkUpdateListOrderFieldQuery != null) { mappingObject.pkUpdateListOrderFieldQuery = this.pkUpdateListOrderFieldQuery; } return mappingObject; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { AggregateCollectionMapping mappingObject = (AggregateCollectionMapping)super.clone(); mappingObject.setTargetForeignKeyToSourceKeys(new HashMap(getTargetForeignKeyToSourceKeys())); mappingObject.setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getSourceKeyFields())); mappingObject.setTargetForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getTargetForeignKeyFields())); mappingObject.aggregateToSourceFieldNames = new HashMap(this.aggregateToSourceFieldNames); mappingObject.nestedAggregateToSourceFieldNames = new HashMap(this.nestedAggregateToSourceFieldNames); if(updateListOrderFieldQuery != null) { mappingObject.updateListOrderFieldQuery = this.updateListOrderFieldQuery; } if(bulkUpdateListOrderFieldQuery != null) { mappingObject.bulkUpdateListOrderFieldQuery = this.bulkUpdateListOrderFieldQuery; } if(pkUpdateListOrderFieldQuery != null) { mappingObject.pkUpdateListOrderFieldQuery = this.pkUpdateListOrderFieldQuery; } return mappingObject; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { AggregateCollectionMapping mappingObject = (AggregateCollectionMapping)super.clone(); mappingObject.setTargetForeignKeyToSourceKeys(new HashMap(getTargetForeignKeyToSourceKeys())); mappingObject.setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getSourceKeyFields())); mappingObject.setTargetForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getTargetForeignKeyFields())); mappingObject.aggregateToSourceFields = new HashMap(this.aggregateToSourceFields); mappingObject.nestedAggregateToSourceFields = new HashMap(this.nestedAggregateToSourceFields); if(updateListOrderFieldQuery != null) { mappingObject.updateListOrderFieldQuery = this.updateListOrderFieldQuery; } if(bulkUpdateListOrderFieldQuery != null) { mappingObject.bulkUpdateListOrderFieldQuery = this.bulkUpdateListOrderFieldQuery; } if(pkUpdateListOrderFieldQuery != null) { mappingObject.pkUpdateListOrderFieldQuery = this.pkUpdateListOrderFieldQuery; } return mappingObject; }
/** * INTERNAL: * The foreign keys and the primary key names are converted to DatabaseFields and stored. The source keys * are not specified by the user so primary keys are extracted from the reference descriptor. */ protected void initializeTargetForeignKeyToSourceKeysWithDefaults(AbstractSession session) throws DescriptorException { if (getTargetForeignKeyFields().isEmpty()) { throw DescriptorException.noTargetForeignKeysSpecified(this); } List<DatabaseField> sourceKeys = getDescriptor().getPrimaryKeyFields(); if (usesIndirection()) { for (DatabaseField field : sourceKeys) { field.setKeepInRow(true); } } setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(sourceKeys)); for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { DatabaseField foreignKeyfield = getTargetForeignKeyFields().get(index); foreignKeyfield = getReferenceDescriptor().buildField(foreignKeyfield); getTargetForeignKeyFields().set(index, foreignKeyfield); } if (getTargetForeignKeyFields().size() != sourceKeys.size()) { throw DescriptorException.targetForeignKeysSizeMismatch(this); } for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { getTargetForeignKeyToSourceKeys().put(getTargetForeignKeyFields().get(index), sourceKeys.get(index)); } }
/** * INTERNAL: * The foreign keys and the primary key names are converted to DatabaseFields and stored. The source keys * are not specified by the user so primary keys are extracted from the reference descriptor. */ protected void initializeTargetForeignKeyToSourceKeysWithDefaults(AbstractSession session) throws DescriptorException { if (getTargetForeignKeyFields().isEmpty()) { throw DescriptorException.noTargetForeignKeysSpecified(this); } List<DatabaseField> sourceKeys = getDescriptor().getPrimaryKeyFields(); if (usesIndirection()) { for (DatabaseField field : sourceKeys) { field.setKeepInRow(true); } } setSourceKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(sourceKeys)); for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { DatabaseField foreignKeyfield = getTargetForeignKeyFields().get(index); foreignKeyfield = getReferenceDescriptor().buildField(foreignKeyfield); getTargetForeignKeyFields().set(index, foreignKeyfield); } if (getTargetForeignKeyFields().size() != sourceKeys.size()) { throw DescriptorException.targetForeignKeysSizeMismatch(this); } for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { getTargetForeignKeyToSourceKeys().put(getTargetForeignKeyFields().get(index), sourceKeys.get(index)); } }