Revision: 6263
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6263&view=rev
Author: manningr
Date: 2011-05-17 01:11:28 +0000 (Tue, 17 May 2011)
Log Message:
-----------
Added support in the dialects for converting a byte array value (from a binary type column) to a n ascii hex string which can be used in SQL statements.
Modified Paths:
--------------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/CommonHibernateDialect.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DB2DialectExt.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectUtils.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/HibernateDialect.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/MySQLDialectExt.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/SybaseDialectExt.java
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/CommonHibernateDialect.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/CommonHibernateDialect.java 2011-05-16 18:22:36 UTC (rev 6262)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/CommonHibernateDialect.java 2011-05-17 01:11:28 UTC (rev 6263)
@@ -995,4 +995,11 @@
return 3;
}
+ @Override
+ public String getBinaryLiteralString(byte[] binaryData) {
+ StringBuilder result = new StringBuilder();
+ result.append("'").append(DialectUtils.toHexString(binaryData)).append("'");
+ return result.toString();
+ }
+
}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DB2DialectExt.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DB2DialectExt.java 2011-05-16 18:22:36 UTC (rev 6262)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DB2DialectExt.java 2011-05-17 01:11:28 UTC (rev 6263)
@@ -1259,4 +1259,14 @@
return 6;
}
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getBinaryLiteralString(byte[])
+ */
+ @Override
+ public String getBinaryLiteralString(byte[] binaryData)
+ {
+ return "BLOB(x'" + DialectUtils.toHexString(binaryData) + "')";
+ }
+
+
}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectUtils.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectUtils.java 2011-05-16 18:22:36 UTC (rev 6262)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectUtils.java 2011-05-17 01:11:28 UTC (rev 6263)
@@ -725,9 +725,11 @@
final ArrayList<String> result = new ArrayList<String>();
// ALTER TABLE localTableName
- // ADD CONSTRAINT constraintName FOREIGN KEY (localColumn1, localColumn2)
+ // ADD CONSTRAINT constraintName FOREIGN KEY (localColumn1,
+ // localColumn2)
// REFERENCES referencedTableName (referencedColumn1, referencedColumn2)
- // MATCH FULL ON UPDATE RESTRICT ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED;
+ // MATCH FULL ON UPDATE RESTRICT ON DELETE NO ACTION DEFERRABLE
+ // INITIALLY DEFERRED;
final StringBuilder sql = new StringBuilder();
sql.append(DialectUtils.ALTER_TABLE_CLAUSE + " ");
@@ -1060,12 +1062,9 @@
}
/**
- * Returns the SQL that is used to change the column type. For example:
- * <code>
+ * Returns the SQL that is used to change the column type. For example: <code>
* ALTER TABLE table_name alter_clause column_name [setClause] data_type
- * </code>
- * or
- * <code>
+ * </code> or <code>
* ALTER TABLE table_name alter_clause column_name column_name [setClause] data_type
* </code>
*
@@ -1117,8 +1116,7 @@
}
/**
- * Returns the SQL that is used to change the column name. For example:
- * <code>
+ * Returns the SQL that is used to change the column name. For example: <code>
* RENAME COLUMN table_name.column_name TO new_column_name
* </code>
*
@@ -1174,38 +1172,46 @@
switch (featureId)
{
case COLUMN_COMMENT_ALTER_TYPE:
- // i18n[DialectUtils.columnCommentUnsupported={0} doesn''t support column comments]
+ // i18n[DialectUtils.columnCommentUnsupported={0} doesn''t support
+ // column comments]
msg = s_stringMgr.getString("DialectUtils.columnCommentUnsupported", dialect.getDisplayName());
break;
case COLUMN_DEFAULT_ALTER_TYPE:
- // i18n[DialectUtils.columnDefaultUnsupported={0} doesn''t support altering a column''s default
+ // i18n[DialectUtils.columnDefaultUnsupported={0} doesn''t support
+ // altering a column''s default
// value]
msg = s_stringMgr.getString("DialectUtils.columnDefaultUnsupported", dialect.getDisplayName());
break;
case COLUMN_DROP_TYPE:
- // i18n[DialectUtils.columnDropUnsupported={0} doesn''t support dropping a column]
+ // i18n[DialectUtils.columnDropUnsupported={0} doesn''t support
+ // dropping a column]
msg = s_stringMgr.getString("DialectUtils.columnDropUnsupported", dialect.getDisplayName());
break;
case COLUMN_NAME_ALTER_TYPE:
- // i18n[DialectUtils.columnNameUnsupported={0} doesn''t support altering a column''s name]
+ // i18n[DialectUtils.columnNameUnsupported={0} doesn''t support
+ // altering a column''s name]
msg = s_stringMgr.getString("DialectUtils.columnNameUnsupported", dialect.getDisplayName());
break;
case COLUMN_NULL_ALTER_TYPE:
- // i18n[DialectUtils.columnNullUnsupported={0} doesn''t support altering a column's nullable
+ // i18n[DialectUtils.columnNullUnsupported={0} doesn''t support
+ // altering a column's nullable
// attribute]
msg = s_stringMgr.getString("DialectUtils.columnNullUnsupported", dialect.getDisplayName());
break;
case COLUMN_TYPE_ALTER_TYPE:
- // i18n[DialectUtils.columnTypeUnsupported={0} doesn''t support altering a column's type attribute]
+ // i18n[DialectUtils.columnTypeUnsupported={0} doesn''t support
+ // altering a column's type attribute]
msg = s_stringMgr.getString("DialectUtils.columnTypeUnsupported", dialect.getDisplayName());
break;
case ADD_PRIMARY_KEY_TYPE:
- // i18n[DialectUtils.addPrimaryKeyUnsupported={0} doesn''t support adding primary keys]
+ // i18n[DialectUtils.addPrimaryKeyUnsupported={0} doesn''t support
+ // adding primary keys]
msg = s_stringMgr.getString("DialectUtils.addPrimaryKeyUnsupported", dialect.getDisplayName());
break;
case DROP_PRIMARY_KEY_TYPE:
- // i18n[DialectUtils.dropPrimaryKeyUnsupported={0} doesn''t support dropping primary keys]
+ // i18n[DialectUtils.dropPrimaryKeyUnsupported={0} doesn''t support
+ // dropping primary keys]
msg = s_stringMgr.getString("DialectUtils.dropPrimaryKeyUnsupported", dialect.getDisplayName());
break;
case CREATE_TABLE_TYPE:
@@ -1254,12 +1260,9 @@
}
/**
- * Returns the SQL command to drop the specified table's primary key. For example:
- * <code>
+ * Returns the SQL command to drop the specified table's primary key. For example: <code>
* alter table table_name drop primary key
- * </code>
- * or
- * <code>
+ * </code> or <code>
* alter table table_name drop constraint [pkName]
* </code>
*
@@ -1527,7 +1530,8 @@
String accessMethod, String[] columns, boolean unique, String tablespace, String constraints,
DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
{
- // CREATE UNIQUE INDEX indexName ON tableName USING btree (column1, column2) TABLESPACE
+ // CREATE UNIQUE INDEX indexName ON tableName USING btree (column1,
+ // column2) TABLESPACE
// WHERE constraints;
final StringBuilder sql = new StringBuilder();
@@ -1765,9 +1769,9 @@
if (primaryKeys != null && primaryKeys.size() > 1)
{
- sql.append(" " + DialectUtils.CONSTRAINT_CLAUSE + " ").append(
- shapeIdentifier(simpleName + "_pkey", prefs, dialect)).append(
- " " + DialectUtils.PRIMARY_KEY_CLAUSE + "(");
+ sql.append(" " + DialectUtils.CONSTRAINT_CLAUSE + " ")
+ .append(shapeIdentifier(simpleName + "_pkey", prefs, dialect))
+ .append(" " + DialectUtils.PRIMARY_KEY_CLAUSE + "(");
for (final TableColumnInfo pkPart : primaryKeys)
{
sql.append(shapeIdentifier(pkPart.getColumnName(), prefs, dialect)).append(",");
@@ -1790,7 +1794,7 @@
{
return getCreateTableSQL(tables, md, dialect, prefs, isJdbcOdbc, false);
}
-
+
public static List<String> getCreateTableSQL(List<ITableInfo> tables, ISQLDatabaseMetaData md,
HibernateDialect dialect, CreateScriptPreferences prefs, boolean isJdbcOdbc, boolean sortColumns)
throws SQLException
@@ -1808,7 +1812,8 @@
final List<PrimaryKeyInfo> pkInfos = getPrimaryKeyInfo(md, ti, isJdbcOdbc);
final List<String> pks = getPKSequenceList(pkInfos);
final TableColumnInfo[] infos = md.getColumnInfo(ti);
- if (sortColumns) {
+ if (sortColumns)
+ {
Arrays.sort(infos);
}
for (final TableColumnInfo tcInfo : infos)
@@ -1828,7 +1833,8 @@
}
else
{
- // in Sybase, DEFAULT keyword must appear prior to NULL/NOT NULL
+ // in Sybase, DEFAULT keyword must appear prior to NULL/NOT
+ // NULL
if (defaultVal != null && !"".equals(defaultVal))
{
result.append(" DEFAULT ");
@@ -1955,8 +1961,9 @@
// AS definition;
final StringBuilder sql = new StringBuilder();
- sql.append(DialectUtils.CREATE_VIEW_CLAUSE + " ").append(
- shapeQualifiableIdentifier(viewName, qualifier, prefs, dialect)).append("\n");
+ sql.append(DialectUtils.CREATE_VIEW_CLAUSE + " ")
+ .append(shapeQualifiableIdentifier(viewName, qualifier, prefs, dialect))
+ .append("\n");
sql.append(" AS ").append(definition);
if (dialect.supportsCheckOptionsForViews() && checkOption != null && !checkOption.equals(""))
{
@@ -2243,7 +2250,8 @@
{
final ArrayList<String> result = new ArrayList<String>();
- // Since dialect doesn't support altering sequences, drop then re-create.
+ // Since dialect doesn't support altering sequences, drop then
+ // re-create.
result.add(dialect.getDropSequenceSQL(sequenceName, false, qualifier, prefs));
result.add(dialect.getCreateSequenceSQL(sequenceName, increment, minimum, maximum, minimum, cache,
cycle, qualifier, prefs));
@@ -2252,9 +2260,11 @@
}
/**
- * Gets the SQL command to insert data into a table. <p/> If the list of columns is empty or null the SQL
- * will look like: INSERT INTO tablename query; <p/> instead of: INSERT INTO tablename ( column1, column2,
- * ... ) query;
+ * Gets the SQL command to insert data into a table.
+ * <p/>
+ * If the list of columns is empty or null the SQL will look like: INSERT INTO tablename query;
+ * <p/>
+ * instead of: INSERT INTO tablename ( column1, column2, ... ) query;
*
* @param tableName
* simple name of the table
@@ -2341,10 +2351,14 @@
if (fromTables == null && setValues == null) { throw new IllegalArgumentException(
"One of fromTables or setValues args must be non-null"); }
- // Since we can use a correlated sub-query to update all rows in one statement, we don't care about the
- // set values, unless fromTables is null, in which case we go with a normal update. Using the set
- // values would require an update statement for each row in the merged table for each column that was
- // merged in, which is incredibly inefficient. However, the API is intended to support database
+ // Since we can use a correlated sub-query to update all rows in one
+ // statement, we don't care about the
+ // set values, unless fromTables is null, in which case we go with a
+ // normal update. Using the set
+ // values would require an update statement for each row in the merged
+ // table for each column that was
+ // merged in, which is incredibly inefficient. However, the API is
+ // intended to support database
// dialects that can't handle correlated sub-queries.
final ArrayList<String> result = new ArrayList<String>();
@@ -2368,7 +2382,7 @@
// // update <destTableName> dest
// // set <setColumnName> = <setValue>
// // where f.<whereColumn> = s.<whereValue>)
- //
+ //
// templateStr =
// "UPDATE $destTableName$ " +
// "SET $columnName$ = $columnValue$ " +
@@ -2425,10 +2439,10 @@
* @param primaryKeys
* can be null
* @param prefs
- * @return
+ * @return
*/
public static List<String> createIndexes(ITableInfo ti, ISQLDatabaseMetaData md,
- List<PrimaryKeyInfo> primaryKeys, CreateScriptPreferences prefs)
+ List<PrimaryKeyInfo> primaryKeys, CreateScriptPreferences prefs)
{
if (ti == null) { throw new IllegalArgumentException("ti cannot be null"); }
if (md == null) { throw new IllegalArgumentException("md cannot be null"); }
@@ -2452,7 +2466,8 @@
}
catch (final SQLException e)
{
- // i18n[DialectUtils.error.getprimarykey=Unable to get primary key info for table {0}]
+ // i18n[DialectUtils.error.getprimarykey=Unable to get primary key
+ // info for table {0}]
final String msg = s_stringMgr.getString("DialectUtils.error.getprimarykey", ti.getSimpleName());
log.error(msg, e);
return result;
@@ -2478,8 +2493,8 @@
final List<IndexColInfo> ixCols = new ArrayList<IndexColInfo>();
ixCols.add(new IndexColInfo(columnName, indexInfo.getOrdinalPosition()));
- buf.put(indexName, new TableIndexInfo(indexInfo.getTableName(), indexInfo.getSchemaName(), indexName, ixCols,
- !indexInfo.isNonUnique()));
+ buf.put(indexName, new TableIndexInfo(indexInfo.getTableName(), indexInfo.getSchemaName(),
+ indexName, ixCols, !indexInfo.isNonUnique()));
}
else
{
@@ -2494,9 +2509,12 @@
if (pkCols.equals(ix.cols))
{
- // Serveral DBs automatically create an index for primary key fields
- // and return this index in getIndexInfo(). We remove this index from the script
- // because it would break the script with an index already exists error.
+ // Serveral DBs automatically create an index for primary key
+ // fields
+ // and return this index in getIndexInfo(). We remove this index
+ // from the script
+ // because it would break the script with an index already
+ // exists error.
continue;
}
@@ -2509,9 +2527,9 @@
indexSQL.append(ix.ixName);
indexSQL.append(" ON ");
- indexSQL.append(formatQualifIntern(ix.table, ix.tableSchema, prefs));
+ indexSQL.append(formatQualifIntern(ix.table, ix.tableSchema, prefs));
- if (ix.cols.size() == 1)
+ if (ix.cols.size() == 1)
{
indexSQL.append("(").append(ix.cols.get(0));
@@ -2571,10 +2589,10 @@
}
}
- sbToAppend.append("ALTER TABLE " + formatQualifIntern(ci.fkTable, ci.fkTableSchema, prefs) + "\n");
- sbToAppend.append("ADD CONSTRAINT " + ci.fkName + "\n");
+ sbToAppend.append("ALTER TABLE " + formatQualifIntern(ci.fkTable, ci.fkTableSchema, prefs) + "\n");
+ sbToAppend.append("ADD CONSTRAINT " + ci.fkName + "\n");
- if (ci.fkCols.size() == 1)
+ if (ci.fkCols.size() == 1)
{
sbToAppend.append("FOREIGN KEY (").append(ci.fkCols.get(0));
@@ -2584,8 +2602,8 @@
}
sbToAppend.append(")\n");
- sbToAppend.append("REFERENCES " + formatQualifIntern(ci.pkTable, ci.pkTableSchema, prefs) + "(");
- sbToAppend.append(ci.pkCols.get(0));
+ sbToAppend.append("REFERENCES " + formatQualifIntern(ci.pkTable, ci.pkTableSchema, prefs) + "(");
+ sbToAppend.append(ci.pkCols.get(0));
for (int j = 1; j < ci.pkCols.size(); j++)
{
sbToAppend.append(",").append(ci.pkCols.get(j));
@@ -2609,8 +2627,8 @@
sbToAppend.append(")\n");
sbToAppend.append("REFERENCES ");
- sbToAppend.append(formatQualifIntern(ci.pkTable, ci.pkTableSchema, prefs));
- sbToAppend.append("\n");
+ sbToAppend.append(formatQualifIntern(ci.pkTable, ci.pkTableSchema, prefs));
+ sbToAppend.append("\n");
sbToAppend.append("(\n");
for (int j = 0; j < ci.pkCols.size(); j++)
{
@@ -2626,27 +2644,26 @@
sbToAppend.append(")");
-
boolean overrideUpdate = prefs.isDeleteRefAction();
String conditionClause = " ON DELETE ";
String overrideAction = prefs.getRefActionByType(prefs.getDeleteAction());
int rule = ci.deleteRule;
-
- String onDeleteClause =
+
+ final String onDeleteClause =
constructFKContraintActionClause(overrideUpdate, conditionClause, overrideAction, rule);
-
+
sbToAppend.append(onDeleteClause);
-
+
overrideUpdate = prefs.isUpdateRefAction();
conditionClause = " ON UPDATE ";
overrideAction = prefs.getRefActionByType(prefs.getUpdateAction());
rule = ci.updateRule;
-
- String onUpdateClause =
+
+ final String onUpdateClause =
constructFKContraintActionClause(overrideUpdate, conditionClause, overrideAction, rule);
sbToAppend.append(onUpdateClause);
- //sbToAppend.append("\n");
+ // sbToAppend.append("\n");
result.add(sbToAppend.toString());
sbToAppend.setLength(0);
}
@@ -2654,112 +2671,120 @@
return result;
}
- private static String formatQualifIntern(String table, String schema, CreateScriptPreferences prefs)
- {
- return formatQualified(table, schema, prefs.isQualifyTableNames(), prefs.isUseDoubleQuotes());
- }
+ private static String formatQualifIntern(String table, String schema, CreateScriptPreferences prefs)
+ {
+ return formatQualified(table, schema, prefs.isQualifyTableNames(), prefs.isUseDoubleQuotes());
+ }
- public static String formatQualified(String table, String schema, boolean qualifyTableNames, boolean useDoubleQuotes)
- {
- if(qualifyTableNames && null != schema && 0 < schema.trim().length())
- {
- if(useDoubleQuotes)
- {
- return "\"" + schema + "\".\"" + table + "\"";
- }
- else
- {
- return schema + "." + table;
- }
- }
- else
- {
- return table;
- }
- }
+ public static String formatQualified(String table, String schema, boolean qualifyTableNames,
+ boolean useDoubleQuotes)
+ {
+ if (qualifyTableNames && null != schema && 0 < schema.trim().length())
+ {
+ if (useDoubleQuotes)
+ {
+ return "\"" + schema + "\".\"" + table + "\"";
+ }
+ else
+ {
+ return schema + "." + table;
+ }
+ }
+ else
+ {
+ return table;
+ }
+ }
- private static String constructFKContraintActionClause(boolean override, String conditionClause,
+ private static String constructFKContraintActionClause(boolean override, String conditionClause,
String overrideAction, int rule)
{
// Bug 2531193: Oracle create table script the "ON UPDATE" is wrong
- StringBuilder tmp = new StringBuilder();
- if (override) {
- if ("NO ACTION".equals(overrideAction)) {
+ final StringBuilder tmp = new StringBuilder();
+ if (override)
+ {
+ if ("NO ACTION".equals(overrideAction))
+ {
return "";
- } else {
+ }
+ else
+ {
tmp.append(conditionClause);
tmp.append(overrideAction);
return tmp.toString();
}
}
-
+
switch (rule)
{
case DatabaseMetaData.importedKeyCascade:
tmp.append(conditionClause);
- if (override) {
+ if (override)
+ {
tmp.append(overrideAction);
- } else {
+ }
+ else
+ {
tmp.append("CASCADE");
}
break;
case DatabaseMetaData.importedKeySetNull:
- if (override) {
+ if (override)
+ {
tmp.append(overrideAction);
- } else {
+ }
+ else
+ {
tmp.append("SET NULL");
}
break;
case DatabaseMetaData.importedKeySetDefault:
- if (override) {
+ if (override)
+ {
tmp.append(overrideAction);
- } else {
+ }
+ else
+ {
tmp.append("SET DEFAULT");
}
break;
case DatabaseMetaData.importedKeyRestrict:
case DatabaseMetaData.importedKeyNoAction:
default:
- // Append nothing - standard says this is equivalent to NO ACTION and some DBs
+ // Append nothing - standard says this is equivalent to NO ACTION
+ // and some DBs
// (e.g. Oracle don't accept ... NO ACTION)
}
return tmp.toString();
}
-
+
private static ConstraintInfo[] getConstraintInfos(ITableInfo ti, ISQLDatabaseMetaData md)
throws SQLException
{
- final ArrayList<ConstraintInfo> ret = new ArrayList<ConstraintInfo>();
- final ForeignKeyInfo[] fkinfos = md.getImportedKeysInfo(ti);
- for (final ForeignKeyInfo fkinfo : fkinfos)
- {
- final Vector<String> fkCols = new Vector<String>();
- final Vector<String> pkCols = new Vector<String>();
+ final ArrayList<ConstraintInfo> ret = new ArrayList<ConstraintInfo>();
+ final ForeignKeyInfo[] fkinfos = md.getImportedKeysInfo(ti);
+ for (final ForeignKeyInfo fkinfo : fkinfos)
+ {
+ final Vector<String> fkCols = new Vector<String>();
+ final Vector<String> pkCols = new Vector<String>();
+ for (final ForeignKeyColumnInfo fkCol : fkinfo.getForeignKeyColumnInfo())
+ {
+ fkCols.add(fkCol.getForeignKeyColumnName());
+ pkCols.add(fkCol.getPrimaryKeyColumnName());
+ }
- for (ForeignKeyColumnInfo fkCol : fkinfo.getForeignKeyColumnInfo())
- {
- fkCols.add(fkCol.getForeignKeyColumnName());
- pkCols.add(fkCol.getPrimaryKeyColumnName());
- }
+ final ConstraintInfo ci =
+ new ConstraintInfo(fkinfo.getForeignKeyTableName(), fkinfo.getForeignKeySchemaName(),
+ fkinfo.getPrimaryKeyTableName(), fkinfo.getPrimaryKeySchemaName(), fkinfo.getSimpleName(),
+ fkCols, pkCols, (short) fkinfo.getDeleteRule(), (short) fkinfo.getUpdateRule());
- ConstraintInfo ci = new ConstraintInfo(
- fkinfo.getForeignKeyTableName(),
- fkinfo.getForeignKeySchemaName(),
- fkinfo.getPrimaryKeyTableName(),
- fkinfo.getPrimaryKeySchemaName(),
- fkinfo.getSimpleName(),
- fkCols,
- pkCols,
- (short) fkinfo.getDeleteRule(),
- (short) fkinfo.getUpdateRule());
+ ret.add(ci);
- ret.add(ci);
+ }
+ return ret.toArray(new ConstraintInfo[ret.size()]);
+ }
- }
- return ret.toArray(new ConstraintInfo[ret.size()]);
- }
-
private static List<PrimaryKeyInfo> getPrimaryKeyInfo(ISQLDatabaseMetaData md, ITableInfo ti,
boolean isJdbcOdbc)
{
@@ -2857,7 +2882,8 @@
final String columnName = shapeIdentifier(column.getColumnName(), prefs, dialect);
final String sequenceName = shapeIdentifier(tableName + "_" + columnName + "_" + "seq", prefs, dialect);
- // TODO Probably want to allow the user to set these sequence properties ??
+ // TODO Probably want to allow the user to set these sequence properties
+ // ??
// Sequence settings.
final String sequenceIncrement = "1";
final String minimum = "1";
@@ -3080,4 +3106,26 @@
return strWithQuotes.replaceAll(tmp.toString(), identifier);
}
+ /**
+ * Converts the specified byte array into a String containing hex characters that represent the nibbles
+ * that form the butes in the array.
+ *
+ * @param bytes
+ * the byte array to convert
+ * @return a hex string representing the bytes in the specified byte array.
+ */
+ public static String toHexString(byte[] bytes)
+ {
+ final char[] hexArray =
+ { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+ final char[] hexChars = new char[bytes.length * 2];
+ int v;
+ for (int j = 0; j < bytes.length; j++)
+ {
+ v = bytes[j] & 0xFF;
+ hexChars[j * 2] = hexArray[v / 16];
+ hexChars[j * 2 + 1] = hexArray[v % 16];
+ }
+ return new String(hexChars);
+ }
}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/HibernateDialect.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/HibernateDialect.java 2011-05-16 18:22:36 UTC (rev 6262)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/HibernateDialect.java 2011-05-17 01:11:28 UTC (rev 6263)
@@ -30,44 +30,47 @@
import org.hibernate.HibernateException;
/**
- * An interface for methods implemented by database dialects for the purpose of handling standard and
- * non-standard SQL and database types.
+ * An interface for methods implemented by database dialects for the purpose of
+ * handling standard and non-standard SQL and database types.
*/
-public interface HibernateDialect extends StringTemplateConstants
-{
+public interface HibernateDialect extends StringTemplateConstants {
/**
- * Get the name of the database type associated with the given <tt>java.sql.Types</tt> typecode.
+ * Get the name of the database type associated with the given
+ * <tt>java.sql.Types</tt> typecode.
*
* @param code
- * <tt>java.sql.Types</tt> typecode
+ * <tt>java.sql.Types</tt> typecode
* @param length
- * the length or precision of the column
+ * the length or precision of the column
* @param precision
- * the precision of the column
+ * the precision of the column
* @param scale
- * the scale of the column
+ * the scale of the column
* @return the database type name
* @throws HibernateException
*/
- String getTypeName(int code, int length, int precision, int scale) throws HibernateException;
+ String getTypeName(int code, int length, int precision, int scale)
+ throws HibernateException;
/**
- * Get the name of the database type associated with the given {@link java.sql.Types} typecode.
+ * Get the name of the database type associated with the given
+ * {@link java.sql.Types} typecode.
*
* @param code
- * The {@link java.sql.Types} typecode
+ * The {@link java.sql.Types} typecode
* @return the database type name
* @throws HibernateException
- * If no mapping was specified for that type.
+ * If no mapping was specified for that type.
*/
public String getTypeName(int code) throws HibernateException;
/**
- * Returns a boolean indicating whether or not the specified database object can be pasted into for this
- * database dialect. Some databases support the notion of schemas where tables live, and in those cases
- * pasting to a database object in the object tree is not really appropriate. However, other databases
- * don't support schemas (like Axion, Firebird)
+ * Returns a boolean indicating whether or not the specified database object
+ * can be pasted into for this database dialect. Some databases support the
+ * notion of schemas where tables live, and in those cases pasting to a
+ * database object in the object tree is not really appropriate. However,
+ * other databases don't support schemas (like Axion, Firebird)
*
* @param info
* @return
@@ -75,205 +78,237 @@
boolean canPasteTo(IDatabaseObjectInfo info);
/**
- * Returns a boolean value indicating whether or not this database dialect supports table creation
- * statements where the table name is prefixed by the schema.
+ * Returns a boolean value indicating whether or not this database dialect
+ * supports table creation statements where the table name is prefixed by
+ * the schema.
*
* @return
*/
boolean supportsSchemasInTableDefinition();
/**
- * Returns the string that should be appended to a column declaration when nulls are allowed in the column.
+ * Returns the string that should be appended to a column declaration when
+ * nulls are allowed in the column.
*
- * @return the "nulls are allowed in this column" string for a table declaration
+ * @return the "nulls are allowed in this column" string for a table
+ * declaration
*/
String getNullColumnString();
/**
- * Returns the name of the aggregate function that determines the max value of an expression.
+ * Returns the name of the aggregate function that determines the max value
+ * of an expression.
*
- * @return the name of the function to be applied to a set to determine the element with the highest
- * numeric value.
+ * @return the name of the function to be applied to a set to determine the
+ * element with the highest numeric value.
*/
String getMaxFunction();
/**
- * Returns the name of the function that measures the length of a character string.
+ * Returns the name of the function that measures the length of a character
+ * string.
*
* @param dataType
- * the java.sql.Types data type. Some databases have different length functions for different
- * data types.
- * @return the name of the function to be applied to a column to determine the length of that column in a
- * particular record.
+ * the java.sql.Types data type. Some databases have different
+ * length functions for different data types.
+ * @return the name of the function to be applied to a column to determine
+ * the length of that column in a particular record.
*/
String getLengthFunction(int dataType);
/**
- * Returns the maximum precision allowed by the database for number type fields that specify the length of
- * the number to the left of the decimal point in digits. If the HibernateDialect implementation doesn't
- * ever use $p in any call to registerColumnType(), then this maximum precsision will not be used.
+ * Returns the maximum precision allowed by the database for number type
+ * fields that specify the length of the number to the left of the decimal
+ * point in digits. If the HibernateDialect implementation doesn't ever use
+ * $p in any call to registerColumnType(), then this maximum precsision will
+ * not be used.
*
* @param dataType
- * the java.sql.Types data type.
- * @return the maximum number that can be used in a column declaration for precision for the specified
- * type.
+ * the java.sql.Types data type.
+ * @return the maximum number that can be used in a column declaration for
+ * precision for the specified type.
*/
in...
[truncated message content] |