/** * INTERNAL: */ public boolean isPrimaryKeyFieldNotSpecified() { return m_pkField.getName().equals(""); }
/** * INTERNAL: */ public boolean isForeignKeyFieldNotSpecified() { return m_fkField.getName().equals(""); }
/** * Return the hashcode of the name, because it is fairly unqiue. */ public int hashCode() { return getName().hashCode(); }
/** * INTERNAL: */ public boolean isPrimaryKeyFieldNotSpecified() { return m_pkField.getName().equals(""); }
/** * INTERNAL: */ public boolean isForeignKeyFieldNotSpecified() { return m_fkField.getName().equals(""); }
/** * PUBLIC: * Return the field name for the query key. */ public String getFieldName() { return getField().getName(); }
protected static void writeUniqueFieldName(Writer writer, DatabaseField field) throws IOException { // EMPLOYEE_EMP_ID writer.write(field.getTableName()); writer.write("_"); writer.write(field.getName()); }
/** * INTERNAL: * Method to return the primary key field name for the given descriptor * metadata. Assumes there is one. */ public String getPrimaryKeyFieldName() { return ((DatabaseField)(getPrimaryKeyFields().iterator().next())).getName(); }
/** * INTERNAL: * Helper method to return a field name from a candidate field name and a * default field name. * * Requires the context from where this method is called to output the * correct logging message when defaulting the field name. */ protected String getName(DatabaseField field, String defaultName, String context) { return getName(field.getName(), defaultName, context); }
/** * INTERNAL: * helper method, don't override. */ protected static void writeFieldsList(Writer writer, Collection fields) throws IOException { boolean isFirst = true; Iterator itFields = fields.iterator(); while(itFields.hasNext()) { if(isFirst) { isFirst = false; } else { writer.write(", "); } DatabaseField field = (DatabaseField)itFields.next(); writer.write(field.getName()); } }
public String toString() { return "=> " + getOutputField().getName(); } }
/** * INTERNAL: * Method to return the primary key field names for the given descriptor * metadata. getPrimaryKeyFieldNames() on ClassDescriptor returns qualified * names. We don't want that. */ public List<String> getPrimaryKeyFieldNames() { List<DatabaseField> primaryKeyFields = getPrimaryKeyFields(); List<String> primaryKeyFieldNames = new ArrayList<String>(primaryKeyFields.size()); for (DatabaseField primaryKeyField : primaryKeyFields) { primaryKeyFieldNames.add(primaryKeyField.getName()); } return primaryKeyFieldNames; }
/** * INTERNAL: * Retrun an expression that updates the write lock */ public Expression getWriteLockUpdateExpression(ExpressionBuilder builder) { return ExpressionMath.add(builder.getField(writeLockField.getName()), 1); }
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; }
/** * entityDescからdataSetのカラム定義を生成します。 */ protected void setupAttributeColumns() { ServerSession serverSession = getEntityDesc().getServerSession(); ClassDescriptor cd = serverSession.getClassDescriptor(getEntityDesc().getEntityClass()); DatabasePlatform platform = serverSession.getPlatform(); for (DatabaseField field : cd.getFields()) { DataTable table = dataSet.getTable(field.getTableName()); int sqlType = platform.getJDBCType(field); String columnName = field.getName(); if (!table.hasColumn(columnName)) { table.addColumn(columnName, ColumnTypes.getColumnType(sqlType)); } } }
/** * entityDescからInheritancePolicyを取得し、継承関連のカラムをdataSetに定義します。 */ protected void setupDiscriminatorColumn() { if (!getEntityDesc().hasDiscriminatorColumn()) { return; } InheritancePolicy inheritancePolicy = getEntityDesc().getInheritancePolicy(); DatabaseField field = inheritancePolicy.getClassIndicatorField(); DataTable table = dataSet.getTable(field.getTableName()); ServerSession serverSession = getEntityDesc().getServerSession(); DatabasePlatform platform = serverSession.getPlatform(); int sqlType = platform.getJDBCType(field); String columnName = field.getName(); if (!table.hasColumn(columnName)) { table.addColumn(columnName, ColumnTypes.getColumnType(sqlType)); } }
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { if (isAttribute() || ((getMapping() != null) && (getMapping().isAggregateObjectMapping() || getMapping().isTransformationMapping()))) { return ((DataExpression)getBaseExpression()).aliasForTable(table); } //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table if ((getMapping() != null) && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) { DatabaseTable alias = getBaseExpression().aliasForTable((DatabaseTable)getMapping().getDescriptor().getTables().firstElement()); alias.setName(alias.getName() + "." + getMapping().getField().getName()); return alias; } return super.aliasForTable(table); }