DatabaseField resolvedDatabaseField = new DatabaseField(); resolvedDatabaseField.setName(childField.getName()); resolvedDatabaseField.setTable(childField.getTable()); resolvedDatabaseField.setType(resolvedParentField.getType()); resolvedDatabaseField.setScale(resolvedParentField.getScale()); resolvedDatabaseField.setLength(resolvedParentField.getLength()); resolvedDatabaseField.setPrecision(resolvedParentField.getPrecision()); resolvedDatabaseField.setUnique(childField.isUnique()); resolvedDatabaseField.setNullable(childField.isNullable()); resolvedDatabaseField.setUpdatable(childField.isUpdatable()); resolvedDatabaseField.setInsertable(childField.isInsertable()); String columnDef = childField.getColumnDefinition(); if(columnDef == null || columnDef.trim().equals("")) { resolvedDatabaseField.setColumnDefinition(resolvedParentField.getColumnDefinition()); resolvedDatabaseField.setColumnDefinition(columnDef);
public String toString() { return this.getQualifiedName(); } }
protected static void writeUniqueFieldName(Writer writer, DatabaseField field) throws IOException { // EMPLOYEE_EMP_ID writer.write(field.getTableName()); writer.write("_"); writer.write(field.getName()); }
/** * INTERNAL: */ protected MetadataPrimaryKeyJoinColumn(String sourceTableName, String targetTableName, String defaultPKFieldName, String defaultFKFieldName) { m_pkField = new DatabaseField(); m_pkField.setName(defaultPKFieldName); m_pkField.setTableName(sourceTableName); m_fkField = new DatabaseField(); m_fkField.setName(defaultFKFieldName); m_fkField.setTableName(targetTableName); m_fkField.setColumnDefinition(DEFAULT_COLUMN_DEFINITION); }
/** * Return the qualified name of the field. */ public String getQualifiedName() { if (hasTableName()) { return getTable().getQualifiedName() + "." + getName(); } else { return getName(); } }
fieldDef.setName(dbField.getName()); if (dbField.getColumnDefinition().length() > 0) { fieldDef.setTypeDefinition(dbField.getColumnDefinition()); } else { Class fieldType = dbField.getType(); fieldType.equals(ClassConstants.ACHAR)) { fieldDef.setSize(dbField.getLength()); } else { if (dbField.getPrecision() > 0) { fieldDef.setSize(dbField.getPrecision()); fieldDef.setSubSize(dbField.getScale()); (databasePlatform.getFieldTypeDefinition(fieldType) == null))) { AbstractSessionLog.getLog().log(SessionLog.FINEST, "field_type_set_to_java_lang_string", dbField.getQualifiedName(), fieldType); fieldDef.setShouldAllowNull(dbField.isNullable()); fieldDef.setUnique(dbField.isUnique());
/** * INTERNAL: * The table of the field is ensured to be unique from the descriptor's tables. * If the field has no table the default table is assigned. * This is used only in initialization. */ public void buildField(DatabaseField field) { DatabaseTable table; if (field.hasTableName()) { table = getTable(field.getTableName()); } else { table = getDefaultTable(); } field.setTable(table); }
/** * INTERNAL: */ public boolean isForeignKeyFieldNotSpecified() { return m_fkField.getName().equals(""); }
/** * 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; }
/** * Determine whether the receiver is equal to a DatabaseField. * Return true if the receiver and field have the same name and table. * Also return true if the table of the receiver or field are unspecfied, * ie. have no name. */ public boolean equals(DatabaseField field) { if (this == field) { return true; } if (field != null) { if (DatabasePlatform.shouldIgnoreCaseOnFieldComparisons()) { if (getName().equalsIgnoreCase(field.getName())) { if ((getTableName().length() == 0) || (field.getTableName().length() == 0)) { return true; } return (getTable().equals(field.getTable())); } } else { if (getName().equals(field.getName())) { if ((getTableName().length() == 0) || (field.getTableName().length() == 0)) { return true; } return (getTable().equals(field.getTable())); } } } return false; }
/** * INTERNAL: * Set the data passed through setCustomSQLArgumentType and useCustomSQLCursorOutputAsResultSet methods. */ protected void afterTranslateCustomQueryUpdateParameter(DatabaseField field, int index, Integer parameterType, Vector updatedParameters, Vector updatedParameterTypes) { for (int j = 0; j < updatedParameters.size(); j++) { DatabaseField updateField = (DatabaseField)updatedParameters.elementAt(j); if (field.equals(updateField)) { Integer updateParameterType = (Integer)updatedParameterTypes.elementAt(j); if (updateParameterType == null) { field.setType(updateField.getType()); } else if (updateParameterType == OUT_CURSOR) { if (parameterType == OUT) { getParameterTypes().setElementAt(OUT_CURSOR, index); } else { throw ValidationException.cannotSetCursorForParameterTypeOtherThanOut(field.getName(), toString()); } } break; } } }
/** * INTERNAL: * A DatabaseField is built from the given field name. */ // * added 9/7/00 by Les Davis // * bug fix for null pointer in initialization of mappings in remote session public DatabaseField buildField(String fieldName) { DatabaseField field = new DatabaseField(fieldName); DatabaseTable table; if (field.hasTableName()) { table = getTable(field.getTableName()); } else if (getDefaultTable() != null) { table = getDefaultTable(); } else { table = getTable(getTableName()); } field.setTable(table); return field; }
pkField.setName(getName(pkField, defaultPKFieldName, MetadataLogger.PK_COLUMN)); pkField.setTableName(getReferenceDescriptor().getPrimaryKeyTableName()); fkField.setName(getName(fkField, defaultFKFieldName, MetadataLogger.FK_COLUMN)); if (fkField.getTableName().equals("")) { fkField.setTableName(m_descriptor.getPrimaryTableName()); if (fkField.isReadOnly()) { mapping.setIsReadOnly(true);
public void printField(DatabaseField field) { if (field == null) { return; } try { // Print the field using either short or long notation i.e. owner + table name. if (shouldPrintQualifiedNames()) { getWriter().write(field.getQualifiedName()); } else { getWriter().write(field.getName()); } } catch (IOException exception) { throw ValidationException.fileError(exception); } }
/** * Build a foriegn key constraint using FieldDefinition.getForeignKeyFieldName(). */ protected ForeignKeyConstraint buildForeignKeyConstraint(FieldDefinition field, DatabasePlatform platform) { Vector sourceFields = new Vector(); Vector targetFields = new Vector(); ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint(); DatabaseField tempTargetField = new DatabaseField(field.getForeignKeyFieldName()); DatabaseField tempSourceField = new DatabaseField(field.getName()); sourceFields.addElement(tempSourceField.getName()); targetFields.addElement(tempTargetField.getName()); fkConstraint.setSourceFields(sourceFields); fkConstraint.setTargetFields(targetFields); fkConstraint.setTargetTable(tempTargetField.getTable().getQualifiedName()); String tempName = buildForeignKeyConstraintName(this.getName(), tempSourceField.getName(), platform.getMaxForeignKeyNameSize()); fkConstraint.setName(tempName); return fkConstraint; }
FieldDefinition fieldDef; if(field.getColumnDefinition().length() == 0){ fieldDef = new FieldDefinition(field.getName(), ConversionManager.getObjectClass(field.getType())); }else{ fieldDef = new FieldDefinition(field.getName(), field.getColumnDefinition());
/** * 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; }
/** * PUBLIC: * Create a new VersionLockingPolicy. Defaults to * storing the lock value in the cache. * @param fieldName specifies the field name for the write * lock field. */ public VersionLockingPolicy(String fieldName) { this(new DatabaseField(fieldName)); }
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: * Retrieve the value for the field. If missing DatabaseRow.noEntry is returned. */ public Object getIndicatingNoEntry(DatabaseField key) { // PERF: Direct variable access. // Optimize check. int index = key.getIndex(); if ((index >= 0) && (index < this.fields.size())) { DatabaseField field = (DatabaseField)this.fields.elementAt(index); if ((field == key) || field.equals(key)) { return this.values.elementAt(index); } } index = this.fields.indexOf(key); if (index >= 0) { // PERF: If the fields index was not set, then set it. if (key.getIndex() == -1) { key.setIndex(index); } return this.values.elementAt(index); } else { return oracle.toplink.essentials.internal.sessions.AbstractRecord.noEntry; } }