/** * Convert the specified schema name to a name that the database will * be able to understand. */ public String convertSchemaCase(DBIdentifier objectName) { return toDBName(namingUtil.convertSchemaCase(objectName), false); }
public DBIdentifier fromDBName(String name, DBIdentifierType id) { return getNamingUtil().fromDBName(name, id); }
/** * Return the sequence name used by databases for the given autoassigned * column. This is only used by databases that require an explicit name * to be used for auto-assign support. */ protected String getGeneratedKeySequenceName(Column col) { return toDBName(namingUtil.getGeneratedKeySequenceName(col, maxAutoAssignNameLength)); }
/** * Return the declaration SQL for the given primary key. This method is * used from within {@link #getCreateTableSQL} and * {@link #getAddPrimaryKeySQL}. Returns * <code>CONSTRAINT <pk name> PRIMARY KEY (<col list>)</code> * by default. */ protected String getPrimaryKeyConstraintSQL(PrimaryKey pk) { // if we have disabled the creation of primary keys, abort here if (!createPrimaryKeys) return null; String name = toDBName(pk.getIdentifier()); if (name != null && reservedWordSet.contains(name.toUpperCase(Locale.ENGLISH))) name = null; StringBuilder buf = new StringBuilder(); if (name != null && CONS_NAME_BEFORE.equals(constraintNameMode)) buf.append("CONSTRAINT ").append(name).append(" "); buf.append("PRIMARY KEY "); if (name != null && CONS_NAME_MID.equals(constraintNameMode)) buf.append(name).append(" "); buf.append("(").append(namingUtil.appendColumns(pk.getColumns())). append(")"); if (name != null && CONS_NAME_AFTER.equals(constraintNameMode)) buf.append(" CONSTRAINT ").append(name); return buf.toString(); }
@Override public String getFullName(Index index) { return toDBName(getNamingUtil().append(DBIdentifierType.INDEX, getFullIdentifier(index.getTable(), false), index.getIdentifier())); }
/** * Make any necessary changes to the given foreign key name to make it * valid for the current DB. */ public DBIdentifier getValidForeignKeyName(DBIdentifier name, Table table, Table toTable) { return namingUtil.getValidForeignKeyIdentifier(name, table, toTable, maxConstraintNameLength); }
/** * Make any necessary changes to the given column name to make it valid * for the current DB. If checkForUniqueness is true, the column name will * be made unique for the specified table. */ public DBIdentifier getValidColumnName(DBIdentifier name, Table table, boolean checkForUniqueness) { return getNamingUtil().getValidColumnIdentifier(name, table, maxColumnNameLength, checkForUniqueness); }
/** * Make any necessary changes to the given sequence name to make it valid * for the current DB. */ public DBIdentifier getValidSequenceName(DBIdentifier name, Schema schema) { return namingUtil.getValidSequenceIdentifier(name, schema, maxTableNameLength); }
/** * Make any necessary changes to the given index name to make it valid * for the current DB. */ public DBIdentifier getValidIndexName(DBIdentifier name, Table table) { return getNamingUtil().getValidIndexIdentifier(name, table, maxIndexNameLength); }
/** * Return the portion of the select statement between the SELECT keyword * and the FROM keyword. */ protected SQLBuffer getSelects(Select sel, boolean distinctIdentifiers, boolean forUpdate) { // append the aliases for all the columns SQLBuffer selectSQL = new SQLBuffer(this); List aliases; if (distinctIdentifiers) aliases = sel.getIdentifierAliases(); else aliases = sel.getSelectAliases(); Object alias; for (int i = 0; i < aliases.size(); i++) { alias = aliases.get(i); if (alias instanceof String) { alias = getNamingUtil().convertAlias((String)alias); } appendSelect(selectSQL, alias, sel, i); if (i < aliases.size() - 1) selectSQL.append(", "); } return selectSQL; }
/** * Return the declaration SQL for the given primary key. This method is * used from within {@link #getCreateTableSQL} and * {@link #getAddPrimaryKeySQL}. Returns * <code>CONSTRAINT <pk name> PRIMARY KEY (<col list>)</code> * by default. */ protected String getPrimaryKeyConstraintSQL(PrimaryKey pk) { // if we have disabled the creation of primary keys, abort here if (!createPrimaryKeys) return null; String name = toDBName(pk.getIdentifier()); if (name != null && reservedWordSet.contains(name.toUpperCase(Locale.ENGLISH))) name = null; StringBuilder buf = new StringBuilder(); if (name != null && CONS_NAME_BEFORE.equals(constraintNameMode)) buf.append("CONSTRAINT ").append(name).append(" "); buf.append("PRIMARY KEY "); if (name != null && CONS_NAME_MID.equals(constraintNameMode)) buf.append(name).append(" "); buf.append("(").append(namingUtil.appendColumns(pk.getColumns())). append(")"); if (name != null && CONS_NAME_AFTER.equals(constraintNameMode)) buf.append(" CONSTRAINT ").append(name); return buf.toString(); }
@Override public String getFullName(Index index) { return toDBName(getNamingUtil().append(DBIdentifierType.INDEX, getFullIdentifier(index.getTable(), false), index.getIdentifier())); }
/** * Make any necessary changes to the given foreign key name to make it * valid for the current DB. */ public DBIdentifier getValidForeignKeyName(DBIdentifier name, Table table, Table toTable) { return namingUtil.getValidForeignKeyIdentifier(name, table, toTable, maxConstraintNameLength); }
/** * Make any necessary changes to the given column name to make it valid * for the current DB. If checkForUniqueness is true, the column name will * be made unique for the specified table. */ public DBIdentifier getValidColumnName(DBIdentifier name, Table table, boolean checkForUniqueness) { return getNamingUtil().getValidColumnIdentifier(name, table, maxColumnNameLength, checkForUniqueness); }
/** * Make any necessary changes to the given sequence name to make it valid * for the current DB. */ public DBIdentifier getValidSequenceName(DBIdentifier name, Schema schema) { return namingUtil.getValidSequenceIdentifier(name, schema, maxTableNameLength); }
/** * Make any necessary changes to the given index name to make it valid * for the current DB. */ public DBIdentifier getValidIndexName(DBIdentifier name, Table table) { return getNamingUtil().getValidIndexIdentifier(name, table, maxIndexNameLength); }
/** * Return the portion of the select statement between the SELECT keyword * and the FROM keyword. */ protected SQLBuffer getSelects(Select sel, boolean distinctIdentifiers, boolean forUpdate) { // append the aliases for all the columns SQLBuffer selectSQL = new SQLBuffer(this); List aliases; if (distinctIdentifiers) aliases = sel.getIdentifierAliases(); else aliases = sel.getSelectAliases(); Object alias; for (int i = 0; i < aliases.size(); i++) { alias = aliases.get(i); if (alias instanceof String) { alias = getNamingUtil().convertAlias((String)alias); } appendSelect(selectSQL, alias, sel, i); if (i < aliases.size() - 1) selectSQL.append(", "); } return selectSQL; }
/** * Return the declaration SQL for the given primary key. This method is * used from within {@link #getCreateTableSQL} and * {@link #getAddPrimaryKeySQL}. Returns * <code>CONSTRAINT <pk name> PRIMARY KEY (<col list>)</code> * by default. */ protected String getPrimaryKeyConstraintSQL(PrimaryKey pk) { // if we have disabled the creation of primary keys, abort here if (!createPrimaryKeys) return null; String name = toDBName(pk.getIdentifier()); if (name != null && reservedWordSet.contains(name.toUpperCase())) name = null; StringBuilder buf = new StringBuilder(); if (name != null && CONS_NAME_BEFORE.equals(constraintNameMode)) buf.append("CONSTRAINT ").append(name).append(" "); buf.append("PRIMARY KEY "); if (name != null && CONS_NAME_MID.equals(constraintNameMode)) buf.append(name).append(" "); buf.append("(").append(namingUtil.appendColumns(pk.getColumns())). append(")"); if (name != null && CONS_NAME_AFTER.equals(constraintNameMode)) buf.append(" CONSTRAINT ").append(name); return buf.toString(); }
@Override public String getFullName(Index index) { return toDBName(getNamingUtil().append(DBIdentifierType.INDEX, getFullIdentifier(index.getTable(), false), index.getIdentifier())); }
/** * Make any necessary changes to the given foreign key name to make it * valid for the current DB. */ public DBIdentifier getValidForeignKeyName(DBIdentifier name, Table table, Table toTable) { return namingUtil.getValidForeignKeyIdentifier(name, table, toTable, maxConstraintNameLength); }