/** * INTERNAL: * Return the target foreign key field names associated with the mapping. * These are in-order with the targetForeignKeyFieldNames. */ public Vector getTargetForeignKeyFieldNames() { Vector fieldNames = new Vector(getTargetForeignKeyFields().size()); for (Enumeration fieldsEnum = getTargetForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * INTERNAL: * Return the target foreign key field names associated with the mapping. * These are in-order with the targetForeignKeyFieldNames. */ public Vector getTargetForeignKeyFieldNames() { Vector fieldNames = new Vector(getTargetForeignKeyFields().size()); for (Enumeration fieldsEnum = getTargetForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * INTERNAL: * Return the target foreign key field names associated with the mapping. * These are in-order with the targetForeignKeyFieldNames. */ public Vector getTargetForeignKeyFieldNames() { Vector fieldNames = new Vector(getTargetForeignKeyFields().size()); for (Enumeration fieldsEnum = getTargetForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { fieldNames.addElement(((DatabaseField)fieldsEnum.nextElement()).getQualifiedName()); } return fieldNames; }
/** * INTERNAL: * Add the associated fields to the appropriate collections. */ public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField) { getTargetForeignKeyFields().addElement(targetForeignKeyField); getSourceKeyFields().addElement(sourceKeyField); }
/** * INTERNAL: * Add the associated fields to the appropriate collections. */ @Override public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField) { getTargetForeignKeyFields().addElement(targetForeignKeyField); getSourceKeyFields().addElement(sourceKeyField); }
/** * INTERNAL: * Add the associated fields to the appropriate collections. */ @Override public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourceKeyField) { getTargetForeignKeyFields().addElement(targetForeignKeyField); getSourceKeyFields().addElement(sourceKeyField); }
@Override public Object getAttributeValueFromObject(Object object) { List sourceFields = ((OneToManyMapping)object).getSourceKeyFields(); List targetFields = ((OneToManyMapping)object).getTargetForeignKeyFields(); List associations = new ArrayList(sourceFields.size()); for (int index = 0; index < sourceFields.size(); index++) { associations.add(new Association(targetFields.get(index), sourceFields.get(index))); } return associations; }
public Object getAttributeValueFromObject(Object object) { List sourceFields = ((OneToManyMapping)object).getSourceKeyFields(); List targetFields = ((OneToManyMapping)object).getTargetForeignKeyFields(); List associations = new ArrayList(sourceFields.size()); for (int index = 0; index < sourceFields.size(); index++) { associations.add(new Association(targetFields.get(index), sourceFields.get(index))); } return associations; }
public Object getAttributeValueFromObject(Object object) { List sourceFields = ((OneToManyMapping)object).getSourceKeyFields(); List targetFields = ((OneToManyMapping)object).getTargetForeignKeyFields(); List associations = new ArrayList(sourceFields.size()); for (int index = 0; index < sourceFields.size(); index++) { associations.add(new Association(targetFields.get(index), sourceFields.get(index))); } return associations; }
protected void addOneToManyMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToManyMapping mapping) { Enumeration targetKeysEnum = mapping.getTargetForeignKeyFields().elements(); Enumeration sourceKeysEnum = mapping.getSourceKeyFields().elements(); while (sourceKeysEnum.hasMoreElements()) { DatabaseField sourceField = (DatabaseField)sourceKeysEnum.nextElement(); DatabaseField targetField = (DatabaseField)targetKeysEnum.nextElement(); method.addLine(mappingName + ".addTargetForeignKeyFieldName(\"" + targetField.getQualifiedName() + "\", \"" + sourceField.getQualifiedName() + "\");"); } }
/** * PUBLIC: * Define the target foreign key relationship in the one-to-many mapping. * This method can be used when the foreign and primary keys * have only a single field each. * (Use #addTargetForeignKeyFieldName(String, String) * for "composite" keys.) * Only the target foreign key field name is specified and the source * (primary) key field is * assumed to be the primary key of the source object. * Because the target object's table must store a foreign key to the source table, * the target object must map that foreign key, this is normally done through a * one-to-one mapping back-reference. Other options include: * <ul> * <li> use a DirectToFieldMapping and maintain the * foreign key fields directly in the target * <li> use a ManyToManyMapping * <li> use an AggregateCollectionMapping * </ul> * @see DirectToFieldMapping * @see ManyToManyMapping * @see AggregateCollectionMapping */ public void setTargetForeignKeyFieldName(String targetForeignKeyFieldName) { getTargetForeignKeyFields().addElement(new DatabaseField(targetForeignKeyFieldName)); }
/** * PUBLIC: * Define the target foreign key relationship in the one-to-many mapping. * This method can be used when the foreign and primary keys * have only a single field each. * (Use #addTargetForeignKeyFieldName(String, String) * for "composite" keys.) * Only the target foreign key field name is specified and the source * (primary) key field is * assumed to be the primary key of the source object. * Because the target object's table must store a foreign key to the source table, * the target object must map that foreign key, this is normally done through a * one-to-one mapping back-reference. Other options include: * <ul> * <li> use a DirectToFieldMapping and maintain the * foreign key fields directly in the target * <li> use a ManyToManyMapping * <li> use an AggregateCollectionMapping * </ul> * @see DirectToFieldMapping * @see ManyToManyMapping * @see AggregateCollectionMapping */ public void setTargetForeignKeyFieldName(String targetForeignKeyFieldName) { getTargetForeignKeyFields().addElement(new DatabaseField(targetForeignKeyFieldName)); }
/** * PUBLIC: * Define the target foreign key relationship in the one-to-many mapping. * This method can be used when the foreign and primary keys * have only a single field each. * (Use #addTargetForeignKeyFieldName(String, String) * for "composite" keys.) * Only the target foreign key field name is specified and the source * (primary) key field is * assumed to be the primary key of the source object. * Because the target object's table must store a foreign key to the source table, * the target object must map that foreign key, this is normally done through a * one-to-one mapping back-reference. Other options include: * <ul> * <li> use a DirectToFieldMapping and maintain the * foreign key fields directly in the target * <li> use a ManyToManyMapping * <li> use an AggregateCollectionMapping * </ul> * @see DirectToFieldMapping * @see ManyToManyMapping * @see AggregateCollectionMapping */ public void setTargetForeignKeyFieldName(String targetForeignKeyFieldName) { getTargetForeignKeyFields().addElement(new DatabaseField(targetForeignKeyFieldName)); }
protected void addOneToManyMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToManyMapping mapping) { Enumeration targetKeysEnum = mapping.getTargetForeignKeyFields().elements(); Enumeration sourceKeysEnum = mapping.getSourceKeyFields().elements(); while (sourceKeysEnum.hasMoreElements()) { DatabaseField sourceField = (DatabaseField)sourceKeysEnum.nextElement(); DatabaseField targetField = (DatabaseField)targetKeysEnum.nextElement(); method.addLine(mappingName + ".addTargetForeignKeyFieldName(\"" + targetField.getQualifiedName() + "\", \"" + sourceField.getQualifiedName() + "\");"); } }
protected void addOneToManyMappingLines(NonreflectiveMethodDefinition method, String mappingName, OneToManyMapping mapping) { Enumeration targetKeysEnum = mapping.getTargetForeignKeyFields().elements(); Enumeration sourceKeysEnum = mapping.getSourceKeyFields().elements(); while (sourceKeysEnum.hasMoreElements()) { DatabaseField sourceField = (DatabaseField)sourceKeysEnum.nextElement(); DatabaseField targetField = (DatabaseField)targetKeysEnum.nextElement(); method.addLine(mappingName + ".addTargetForeignKeyFieldName(\"" + targetField.getQualifiedName() + "\", \"" + sourceField.getQualifiedName() + "\");"); } }
@Override 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()); } } });
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()); } } });
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()); } } });
if (getTargetForeignKeyFields().isEmpty()) { if (shouldInitializeSelectionCriteria() || requiresDataModificationEvents() || getContainerPolicy().requiresDataModificationEvents()) { throw DescriptorException.noTargetForeignKeysSpecified(this); if (getTargetForeignKeyFields().size() != getSourceKeyFields().size()) { throw DescriptorException.targetForeignKeysSizeMismatch(this); for (int index = 0; index < getTargetForeignKeyFields().size(); index++) { DatabaseField field = getReferenceDescriptor().buildField(getTargetForeignKeyFields().get(index)); getTargetForeignKeyFields().set(index, field); Iterator<DatabaseField> targetForeignKeys = getTargetForeignKeyFields().iterator(); Iterator<DatabaseField> sourceKeys = getSourceKeyFields().iterator(); while (targetForeignKeys.hasNext()) {
/** * This method would allow customers to get the potential selection criteria for a mapping * prior to initialization. This would allow them to more easily create an amendment method * that would amend the SQL for the join. * * CR#3922 - This method is almost the same as buildDefaultSelectionCriteria() the difference * is that TargetForeignKeysToSourceKeys contains more information after login then SourceKeyFields * contains before login. */ public Expression buildSelectionCriteria() { //CR3922 Expression selectionCriteria = null; Expression builder = new ExpressionBuilder(); Enumeration sourceKeys = getSourceKeyFields().elements(); for (Enumeration targetForeignKeys = getTargetForeignKeyFields().elements(); targetForeignKeys.hasMoreElements();) { DatabaseField targetForeignKey = (DatabaseField)targetForeignKeys.nextElement(); DatabaseField sourceKey = (DatabaseField)sourceKeys.nextElement(); Expression partialSelectionCriteria = builder.getField(targetForeignKey).equal(builder.getParameter(sourceKey)); selectionCriteria = partialSelectionCriteria.and(selectionCriteria); } return selectionCriteria; }