public abstract class BaseLiaison extends Object implements DatabaseLiaison
| Constructor and Description |
|---|
BaseLiaison() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addColumn(Connection conn,
String table,
String column,
ColumnDefinition newColumnDef,
boolean check)
Adds a column to a table with the given definition.
|
boolean |
addColumn(Connection conn,
String table,
String column,
String definition,
boolean check)
Adds a column to a table with the given definition.
|
boolean |
addIndexToTable(Connection conn,
String table,
List<String> columns,
String ixName,
boolean unique)
Adds a named index to a table on the given columns.
|
void |
addPrimaryKey(Connection conn,
String table,
List<String> columns)
Adds a primary key to a table of the given name and on the given columns.
|
boolean |
changeColumn(Connection conn,
String table,
String column,
String type,
Boolean nullable,
Boolean unique,
String defaultValue)
Alter the definition, but not the name, of a given column on a given table.
|
abstract String |
columnSQL(String column)
Returns the proper SQL to identify a column.
|
abstract void |
createGenerator(Connection conn,
String tableName,
String columnName,
int initialValue)
Initializes the column value auto-generator described in
DatabaseLiaison.lastInsertedId(java.sql.Connection, java.lang.String, java.lang.String). |
boolean |
createTableIfMissing(Connection conn,
String table,
List<String> columns,
List<ColumnDefinition> definitions,
List<List<String>> uniqueConstraintColumns,
List<String> primaryKeyColumns)
Created a new table of the given name with the given column names and column definitions;
the given set of unique constraints (or null) and the given primary key columns (or null).
|
boolean |
createTableIfMissing(Connection conn,
String table,
List<String> columns,
List<ColumnDefinition> declarations,
List<String> primaryKeyColumns)
Created a new table of the given name with the given column names and column definitions;
the given set of unique constraints (or null) and the given primary key columns (or null).
|
abstract void |
deleteGenerator(Connection conn,
String tableName,
String columnName)
Deletes the column value auto-generator described in
DatabaseLiaison.lastInsertedId(java.sql.Connection, java.lang.String, java.lang.String). |
boolean |
dropColumn(Connection conn,
String table,
String column)
Drops the given column from the given table.
|
void |
dropIndex(Connection conn,
String table,
String index)
Drops the named index from the given table.
|
void |
dropPrimaryKey(Connection conn,
String table,
String pkName)
Deletes the primary key from a table, if it exists.
|
boolean |
dropTable(Connection conn,
String name)
Drops the given table and returns true if the table exists, else returns false.
|
String |
expandDefinition(ColumnDefinition def)
Create an SQL string that summarizes a column definition in that format generally accepted
in table creation and column addition statements, e.g.
|
abstract String |
indexSQL(String index)
Returns the proper SQL to identify an index.
|
abstract boolean |
isDuplicateRowException(SQLException sqe)
Determines whether or not the supplied SQL exception was caused by a duplicate row being
inserted into a table with a unique key.
|
abstract boolean |
isTransientException(SQLException sqe)
Determines whether or not the supplied SQL exception is a transient failure, meaning one
that is not related to the SQL being executed, but instead to the environment at the time of
execution, like the connection to the database having been lost.
|
int |
lastInsertedId(Connection conn,
Statement istmt,
String table,
String column)
Attempts as dialect-agnostic an interface as possible to the ability of certain databases to
auto-generated numerical values for i.e.
|
int |
lastInsertedId(Connection conn,
String table,
String column)
Deprecated.
|
abstract boolean |
matchesURL(String url)
Indicates whether or not this database liaison is the proper liaison for the specified
database URL.
|
boolean |
renameColumn(Connection conn,
String table,
String from,
String to,
ColumnDefinition newColumnDef)
Alter the name, but not the definition, of a given column on a given table.
|
boolean |
tableContainsColumn(Connection conn,
String table,
String column)
Returns true if the specified table exists and contains a column with the specified name;
false if either condition does not hold true.
|
boolean |
tableContainsIndex(Connection conn,
String table,
String index)
Returns true if the specified table exists and contains an index of the specified name;
false if either conditions does not hold true.
|
boolean |
tableExists(Connection conn,
String name)
Returns true if the table with the specified name exists, false if it does not.
|
abstract String |
tableSQL(String table)
Returns the proper SQL to identify a table.
|
public abstract boolean matchesURL(String url)
DatabaseLiaisonmatchesURL in interface DatabaseLiaisonpublic abstract boolean isDuplicateRowException(SQLException sqe)
DatabaseLiaisonisDuplicateRowException in interface DatabaseLiaisonpublic abstract boolean isTransientException(SQLException sqe)
DatabaseLiaisonisTransientException in interface DatabaseLiaison@Deprecated public int lastInsertedId(Connection conn, String table, String column) throws SQLException
lastInsertedId in interface DatabaseLiaisonSQLExceptionpublic int lastInsertedId(Connection conn, Statement istmt, String table, String column) throws SQLException
DatabaseLiaisonlastInsertedId in interface DatabaseLiaisonistmt - the insert statement that generated the keys. May be null if the ORM doesn't
have the statement handy.SQLException - if we are unable to obtain the last inserted id.public boolean tableExists(Connection conn, String name) throws SQLException
DatabaseLiaisontableExists in interface DatabaseLiaisonSQLExceptionpublic boolean tableContainsColumn(Connection conn, String table, String column) throws SQLException
DatabaseLiaisontableContainsColumn in interface DatabaseLiaisonSQLExceptionpublic boolean tableContainsIndex(Connection conn, String table, String index) throws SQLException
DatabaseLiaisontableContainsIndex in interface DatabaseLiaisonSQLExceptionpublic boolean addIndexToTable(Connection conn, String table, List<String> columns, String ixName, boolean unique) throws SQLException
DatabaseLiaisonaddIndexToTable in interface DatabaseLiaisonSQLExceptionpublic void addPrimaryKey(Connection conn, String table, List<String> columns) throws SQLException
DatabaseLiaisonaddPrimaryKey in interface DatabaseLiaisonSQLExceptionpublic void dropIndex(Connection conn, String table, String index) throws SQLException
DatabaseLiaisondropIndex in interface DatabaseLiaisonSQLExceptionpublic void dropPrimaryKey(Connection conn, String table, String pkName) throws SQLException
DatabaseLiaisondropPrimaryKey in interface DatabaseLiaisonSQLExceptionpublic boolean addColumn(Connection conn, String table, String column, String definition, boolean check) throws SQLException
DatabaseLiaisonaddColumn in interface DatabaseLiaisonSQLExceptionpublic boolean addColumn(Connection conn, String table, String column, ColumnDefinition newColumnDef, boolean check) throws SQLException
DatabaseLiaisonaddColumn in interface DatabaseLiaisonSQLExceptionpublic boolean changeColumn(Connection conn, String table, String column, String type, Boolean nullable, Boolean unique, String defaultValue) throws SQLException
DatabaseLiaisonchangeColumn in interface DatabaseLiaisonSQLExceptionpublic boolean renameColumn(Connection conn, String table, String from, String to, ColumnDefinition newColumnDef) throws SQLException
DatabaseLiaisonrenameColumn in interface DatabaseLiaisonnewColumnDef - the full definition of the new column, including its new name (MySQL
requires this for a column rename).SQLExceptionpublic abstract void createGenerator(Connection conn, String tableName, String columnName, int initialValue) throws SQLException
DatabaseLiaisonDatabaseLiaison.lastInsertedId(java.sql.Connection, java.lang.String, java.lang.String). This
should be idempotent (meaning the generator may already exist in which case this method
should have no negative effect like resetting it).createGenerator in interface DatabaseLiaisonSQLExceptionpublic abstract void deleteGenerator(Connection conn, String tableName, String columnName) throws SQLException
DatabaseLiaisonDatabaseLiaison.lastInsertedId(java.sql.Connection, java.lang.String, java.lang.String).deleteGenerator in interface DatabaseLiaisonSQLExceptionpublic boolean dropColumn(Connection conn, String table, String column) throws SQLException
DatabaseLiaisondropColumn in interface DatabaseLiaisonSQLExceptionpublic boolean createTableIfMissing(Connection conn, String table, List<String> columns, List<ColumnDefinition> declarations, List<String> primaryKeyColumns) throws SQLException
DatabaseLiaisoncreateTableIfMissing in interface DatabaseLiaisonSQLExceptionpublic boolean createTableIfMissing(Connection conn, String table, List<String> columns, List<ColumnDefinition> definitions, List<List<String>> uniqueConstraintColumns, List<String> primaryKeyColumns) throws SQLException
DatabaseLiaisoncreateTableIfMissing in interface DatabaseLiaisonSQLExceptionpublic boolean dropTable(Connection conn, String name) throws SQLException
DatabaseLiaisondropTable in interface DatabaseLiaisonSQLExceptionpublic abstract String tableSQL(String table)
DatabaseLiaisontableSQL in interface DatabaseLiaisonpublic abstract String columnSQL(String column)
DatabaseLiaisoncolumnSQL in interface DatabaseLiaisonpublic abstract String indexSQL(String index)
DatabaseLiaisonindexSQL in interface DatabaseLiaisonpublic String expandDefinition(ColumnDefinition def)
INTEGER UNIQUE NOT NULL
DEFAULT 100.expandDefinition in interface DatabaseLiaisonCopyright © 2015. All rights reserved.