/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { this.getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); this.getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); this.getForeignKeyFields().add(sourceForeignKeyField); this.setIsForeignKeyRelationship(true); }
/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ @Override public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); getForeignKeyFields().add(sourceForeignKeyField); setIsForeignKeyRelationship(true); }
/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ @Override public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); getForeignKeyFields().add(sourceForeignKeyField); setIsForeignKeyRelationship(true); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ public Vector extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Vector result = new Vector(primaryKeyFields.size()); for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = (DatabaseField)getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return new Vector(1); } result.addElement(row.get(sourceKeyField)); } return result; }
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)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(association.getKey(), association.getValue()); mapping.getTargetToSourceKeyFields().put(association.getValue(), association.getKey()); } } });
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)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()); } } });
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)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()); } } });
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size())); clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size())); clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size())); Map setOfFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator targetKeyIterator = getTargetToSourceKeyFields().keySet().iterator(); while (targetKeyIterator.hasNext()) { DatabaseField targetField = (DatabaseField)targetKeyIterator.next(); DatabaseField sourceField = (DatabaseField)getTargetToSourceKeyFields().get(targetField); setOfFields.put(sourceField, sourceClone); clone.getTargetToSourceKeyFields().put(targetClone, sourceClone);
clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size())); clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size())); clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size())); Map setOfFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator targetKeyIterator = getTargetToSourceKeyFields().keySet().iterator(); while (targetKeyIterator.hasNext()) { DatabaseField targetField = (DatabaseField)targetKeyIterator.next(); DatabaseField sourceField = getTargetToSourceKeyFields().get(targetField); setOfFields.put(sourceField, sourceClone); clone.getTargetToSourceKeyFields().put(targetClone, sourceClone);
clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size())); clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size())); clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size())); Map setOfFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator targetKeyIterator = getTargetToSourceKeyFields().keySet().iterator(); while (targetKeyIterator.hasNext()) { DatabaseField targetField = (DatabaseField)targetKeyIterator.next(); DatabaseField sourceField = getTargetToSourceKeyFields().get(targetField); setOfFields.put(sourceField, sourceClone); clone.getTargetToSourceKeyFields().put(targetClone, sourceClone);
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. */ @Override public Object extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row) { List primaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields(); Object[] result = new Object[primaryKeyFields.size()]; for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField targetKeyField = (DatabaseField)primaryKeyFields.get(index); DatabaseField sourceKeyField = getTargetToSourceKeyFields().get(targetKeyField); if (sourceKeyField == null) { return null; } result[index] = row.get(sourceKeyField); if (getReferenceDescriptor().getCachePolicy().getCacheKeyType() == CacheKeyType.ID_VALUE) { return result[index]; } } return new CacheId(result); }