/** * INTERNAL: * If there are any fields associated with this expression, return them */ public DatabaseField getClonedField() { return (DatabaseField)getField().clone(); }
/** * INTERNAL: * If there are any fields associated with this expression, return them */ public Vector getClonedFields() { Vector result = new Vector(1); result.addElement(getField().clone()); return result; }
/** * INTERNAL: * Helper method to clone vector of fields (used in aggregate initialization cloning). */ protected Vector cloneFields(Vector fields) { Vector clonedFields = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); for (Enumeration fieldsEnum = fields.elements(); fieldsEnum.hasMoreElements();) { clonedFields.addElement(((DatabaseField)fieldsEnum.nextElement()).clone()); } return clonedFields; }
/** * Alias the supplied fields with respect to the expression node. Return copies of the fields */ protected Vector aliasFields(ObjectExpression node, Vector fields) { Vector result = new Vector(fields.size()); for (Enumeration e = fields.elements(); e.hasMoreElements();) { DatabaseField eachField = (DatabaseField)((DatabaseField)e.nextElement()).clone(); eachField.setTable(node.aliasForTable(eachField.getTable())); result.addElement(eachField); } return result; }
/** * INTERNAL: * Clone the policy */ public Object clone() { InheritancePolicy clone = null; try { clone = (InheritancePolicy)super.clone(); if (hasClassIndicator()) { clone.setClassIndicatorField((DatabaseField)clone.getClassIndicatorField().clone()); } } catch (Exception exception) { throw new InternalError("clone failed"); } return clone; }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ public Object clone() { AbstractDirectMapping clone = (AbstractDirectMapping)super.clone(); // Field must be cloned so aggregates do not share fields. clone.setField((DatabaseField)getField().clone()); return clone; }
/** * INTERNAL: * Alias the database field for our current environment */ protected void initializeAliasedField() { DatabaseField tempField = (DatabaseField)getField().clone(); DatabaseTable aliasedTable = getAliasedTable(); // Put in a special check here so that if the aliasing does nothing we don't cache the // result because it's invalid. This saves us from caching premature data if e.g. debugging // causes us to print too early" // if (aliasedTable.equals(getField().getTable())) { // return; // } else { aliasedField = tempField; aliasedField.setTable(aliasedTable); // } }
/** * INTERNAL: * Alias the database field for our current environment */ private void initializeAliasedField() { DatabaseField tempField = (DatabaseField)getField().clone(); DatabaseTable aliasedTable = getAliasedTable(); // Put in a special check here so that if the aliasing does nothing we don't cache the // result because it's invalid. This saves us from caching premature data if e.g. debugging // causes us to print too early" // if (aliasedTable.equals(getField().getTable())) { // return; // } else { aliasedField = tempField; aliasedField.setTable(aliasedTable); // } }
DatabaseField fieldClone = (DatabaseField)field.clone(); setOfFields.put(field, fieldClone); clone.getForeignKeyFields().addElement(fieldClone); targetClone = (DatabaseField)targetField.clone(); setOfFields.put(targetField, targetClone); sourceClone = (DatabaseField)sourceField.clone(); setOfFields.put(sourceField, sourceClone); targetClone = (DatabaseField)targetField.clone(); setOfFields.put(targetField, targetClone); sourceClone = (DatabaseField)sourceField.clone(); setOfFields.put(sourceField, sourceClone);
protected void initializeSelectionStatement(AbstractSession session) { SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(getReferenceTable()); statement.addField((DatabaseField)getDirectField().clone()); statement.addField((DatabaseField)getDirectKeyField().clone()); statement.setWhereClause(getSelectionCriteria()); statement.normalize(session, null); getSelectionQuery().setSQLStatement(statement); }
public InOutputParameterForCallableStatement(Object inParameter, DatabaseField outField, DatabasePlatform platform) { if ((outField.getType() == null) && (inParameter != null)) { DatabaseField typeField = (DatabaseField)outField.clone(); if (inParameter instanceof DatabaseField) { typeField.setType(((DatabaseField)inParameter).getType()); } else { typeField.setType(inParameter.getClass()); } outField = typeField; } obj = outField; prepare(platform); if (inParameter == null) { this.inParameter = getOutputField(); } else { this.inParameter = inParameter; } }
/** * INTERNAL: * searches first descriptor than its ReturningPolicy for an equal field */ public DatabaseField getTypedField(DatabaseField field) { boolean mayBeMoreThanOne = hasMultipleTables() && !field.hasTableName(); DatabaseField foundField = null; for (int j = 0; j < getFields().size(); j++) { DatabaseField descField = (DatabaseField)getFields().elementAt(j); if (field.equals(descField)) { if (descField.getType() != null) { foundField = descField; if (!mayBeMoreThanOne || descField.getTable().equals(getDefaultTable())) { break; } } } } if (foundField != null) { foundField = (DatabaseField)foundField.clone(); if (!field.hasTableName()) { foundField.setTableName(""); } } return foundField; }
protected void initializeSelectionStatement(AbstractSession session) { SQLSelectStatement statement = new SQLSelectStatement(); statement.addTable(getReferenceTable()); statement.addField((DatabaseField)getDirectField().clone()); statement.setWhereClause(getSelectionCriteria()); statement.normalize(session, null); getSelectionQuery().setSQLStatement(statement); }
for (int pkIndex = 0; pkIndex < primaryKeyFields.size(); pkIndex++) { DatabaseField primaryKeyField = (DatabaseField)primaryKeyFields.get(pkIndex); DatabaseField secondaryKeyField = (DatabaseField)primaryKeyField.clone(); secondaryKeyField.setTable(table); newKeyMapping.put(primaryKeyField, secondaryKeyField);
/** * INTERNAL: (Override from EmbeddedAccesor) * * Process the embeddable class and gather up our 'original' collection of * primary key fields. They are original because they may change with the * specification of an attribute override. */ protected MetadataDescriptor processEmbeddableClass() { MetadataDescriptor embeddableDescriptor = super.processEmbeddableClass(); // After processing the embeddable class, we need to gather our // primary keys fields that we will eventually set on the owning // descriptor metadata. if (isEmbeddedId() && ! m_descriptor.ignoreIDs()) { if (embeddableDescriptor.getMappings().isEmpty()) { String accessType = embeddableDescriptor.usesPropertyAccess() ? AccessType.PROPERTY.name() : AccessType.FIELD.name(); m_validator.throwEmbeddedIdHasNoAttributes(m_descriptor.getJavaClass(), embeddableDescriptor.getJavaClass(), accessType); } for (DatabaseMapping mapping : embeddableDescriptor.getMappings()) { DatabaseField field = (DatabaseField) mapping.getField().clone(); field.setTableName(m_descriptor.getPrimaryTableName()); m_idFields.put(mapping.getAttributeName(), field); } } return embeddableDescriptor; } }
List primaryKeyFields = getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseField primaryKey = (DatabaseField)((DatabaseField)primaryKeyFields.get(index)).clone(); primaryKeyVector.add(primaryKey);
field = (DatabaseField) field.clone(); field.setType(getResultType());
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { if (isAttribute()) { printer.printField(getAliasedField()); } // If the mapping is a direct collection then this falls into a gray area. // It must be treated as an attribute at this moment for it has a direct field. // However it is not an attribute in the sense that it also represents a foreign // reference and a mapping criteria has been added. // For bug 2900974 these are now handled as non-attributes during normalize but // as attributes when printing SQL. // if ((getMapping() != null) && getMapping().isDirectCollectionMapping()) { DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping(); // The aliased table comes for free as it was a required part of the join criteria. TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable()); DatabaseTable aliasedTable = table.aliasForTable(table.getTable()); DatabaseField aliasedField = (DatabaseField)directCollectionMapping.getDirectField().clone(); aliasedField.setTable(aliasedTable); printer.printField(aliasedField); } }