/** * INTERNAL: This methods clones all the fields and ensures that each collection refers to the * same clones. */ @Override public Object clone() { VariableOneToOneMapping clone = (VariableOneToOneMapping) super.clone(); Map setOfKeys = new HashMap(getSourceToTargetQueryKeyNames().size()); Map sourceToTarget = new HashMap(getSourceToTargetQueryKeyNames().size()); Vector foreignKeys = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance( getForeignKeyFields().size()); if (getTypeField() != null) { clone.setTypeField((DatabaseField) this.getTypeField().clone()); } for (Iterator enumtr = getSourceToTargetQueryKeyNames().keySet().iterator(); enumtr.hasNext(); ) { // Clone the SourceKeyFields DatabaseField field = (DatabaseField) enumtr.next(); DatabaseField clonedField = (DatabaseField) field.clone(); setOfKeys.put(field, clonedField); // on the next line I'm cloning the query key names sourceToTarget.put(clonedField, getSourceToTargetQueryKeyNames().get(field)); } for (Enumeration enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements(); ) { DatabaseField field = (DatabaseField) enumtr.nextElement(); foreignKeys.addElement(setOfKeys.get(field)); } clone.setSourceToTargetQueryKeyFields(sourceToTarget); clone.setForeignKeyFields(foreignKeys); clone.setTypeIndicatorTranslation(new HashMap(this.getTypeIndicatorTranslation())); return clone; }