private boolean isPrimaryKeyColumn (ColumnElement column) { if (column != null) { KeyElement key = column.getDeclaringTable().getPrimaryKey(); return ((key != null) && (key.getColumn(column.getName()) != null)); } return false; } private boolean isExactMatch (ArrayList columns1,
private boolean isPrimaryKeyColumn (ColumnElement column) { if (column != null) { KeyElement key = column.getDeclaringTable().getPrimaryKey(); return ((key != null) && (key.getColumn(column.getName()) != null)); } return false; } private boolean isExactMatch (ArrayList columns1,
/** * createIndexDDL has been added for Symfoware support. Returns DDL in String form * to create index. The returned string has the format: * <pre> * CREATE INDEX table_name.table_name KEY(id, name) * </pre> * @param table Table for which DDL is to be created. * @return DDL to create index. */ private static String createIndexDDL(TableElement table) { String[] twoParam = { table.getName().getName() , getColumnNames(table.getPrimaryKey().getColumns()) }; return DDLTemplateFormatter.formatCreateIndex(twoParam); }
createCreateTableDDL(table, mappingPolicy)); if (table.getPrimaryKey() != null) { createIndexDDL.add(createIndexDDL(table));
public void validate () throws ModelValidationException { String className = getClassName(); MappingClassElement mappingClass = getMappingClass(className); if (mappingClass != null) { List tables = mappingClass.getTables(); if (tables.size() > 0) { String tableName = ((MappingTableElement)tables.get(0)).getName(); TableElement table = getTable(tableName, getSchemaForClass(className)); List columns = getUnmappedColumnNames( ((table != null) ? table.getPrimaryKey() : null), mappingClass); if ((columns != null) && (columns.size() > 0)) { throw new ModelValidationException( ModelValidationException.WARNING, getOffendingObject(null), I18NHelper.getMessage(getMessages(), "util.validation.class_key_column_missing", //NOI18N className, tableName, StringHelper.arrayToSeparatedList(columns))); } } } } private List getUnmappedColumnNames (KeyElement primaryKey,
public void validate () throws ModelValidationException { String className = getClassName(); MappingClassElement mappingClass = getMappingClass(className); if (mappingClass != null) { List tables = mappingClass.getTables(); if (tables.size() > 0) { String tableName = ((MappingTableElement)tables.get(0)).getName(); TableElement table = getTable(tableName, getSchemaForClass(className)); List columns = getUnmappedColumnNames( ((table != null) ? table.getPrimaryKey() : null), mappingClass); if ((columns != null) && (columns.size() > 0)) { throw new ModelValidationException( ModelValidationException.WARNING, getOffendingObject(null), I18NHelper.getMessage(getMessages(), "util.validation.class_key_column_missing", //NOI18N className, tableName, StringHelper.arrayToSeparatedList(columns))); } } } } private List getUnmappedColumnNames (KeyElement primaryKey,
/** * Returns DDL in String form to create a primary key constraint. The * string has the format: * <pre> * CONSTRAINT pk_name PRIMARY KEY(id, name) * </pre> * @param table Table for which constraint DDL is returned. * @return DDL to create a PK constraint or null if there is no PK. */ private static String createPrimaryKeyConstraint(TableElement table) { String rc = null; UniqueKeyElement pk = table.getPrimaryKey(); if (pk != null) { String[] twoParams = new String[2]; twoParams[0] = pk.getName().getName(); twoParams[1] = getColumnNames(pk.getColumns()); rc = DDLTemplateFormatter.formatPKConstraint(twoParams); } return rc; }
public void validate () throws ModelValidationException { if (primaryTable != null) { String className = getClassName(); String schemaName = getSchemaForClass(className); if (schemaName == null) { throw constructClassException(className, null, "util.validation.schema_not_set"); //NOI18N } else { String tableName = primaryTable.getName(); TableElement table = getTable(tableName, schemaName); if ((table != null) && (table.getPrimaryKey() == null)) { throw new ModelValidationException( getOffendingObject(null), I18NHelper.getMessage(getMessages(), "util.validation.table_no_primarykey", //NOI18N new Object[]{tableName, className})); } } } } };
public void validate () throws ModelValidationException { if (primaryTable != null) { String className = getClassName(); String schemaName = getSchemaForClass(className); if (schemaName == null) { throw constructClassException(className, null, "util.validation.schema_not_set"); //NOI18N } else { String tableName = primaryTable.getName(); TableElement table = getTable(tableName, schemaName); if ((table != null) && (table.getPrimaryKey() == null)) { throw new ModelValidationException( getOffendingObject(null), I18NHelper.getMessage(getMessages(), "util.validation.table_no_primarykey", //NOI18N new Object[]{tableName, className})); } } } } };
UniqueKeyElement uke = primTabEl.getPrimaryKey();
UniqueKeyElement key = table.getPrimaryKey(); MappingTableElement mappingTable = new MappingTableElementImpl(table, this);
UniqueKeyElement key = table.getPrimaryKey(); MappingTableElement mappingTable = new MappingTableElementImpl(table, this);
TableElement primaryTable = getTableElement(primaryTableName, knownTables, schema); UniqueKeyElement pk = primaryTable.getPrimaryKey(); ForeignKeyElement fks[] = primaryTable.getForeignKeys(); Iterator iter = primaryTableColumns.iterator();
ForeignKeyElement fkey = new ForeignKeyElement(fkeyImpl, declaringTbl); UniqueKeyElement pk = refTbl.getPrimaryKey(); ColumnElement [] pkColumns = pk.getColumns(); String refTblName = refTbl.getName().getName();