public abstract class PlatformImplBase extends JdbcSupport implements Platform
| Modifier and Type | Field and Description |
|---|---|
protected static String |
MODEL_DEFAULT_NAME
The default name for models read from the database, if no name as given.
|
| Constructor and Description |
|---|
PlatformImplBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterInsert(Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been inserted into
the specified table.
|
protected void |
afterUpdate(Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been updated in
the specified table.
|
void |
alterModel(Connection connection,
Database currentModel,
Database desiredModel,
boolean continueOnError)
Alters the given live database model so that it match the desired model.
|
void |
alterModel(Connection connection,
Database currentModel,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the given live database model so that it match the desired model.
|
void |
alterModel(Database currentModel,
Database desiredModel,
boolean continueOnError)
Alters the given live database model so that it match the desired model, using the default database conneciton.
|
void |
alterModel(Database currentModel,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the given live database model so that it match the desired model, using the default database conneciton.
|
void |
alterTables(Connection connection,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
protected void |
beforeInsert(Connection connection,
Table table)
Allows platforms to issue statements directly before rows are inserted into
the specified table.
|
protected void |
beforeUpdate(Connection connection,
Table table)
Allows platforms to issue statements directly before rows are updated in
the specified table.
|
void |
createDatabase(String jdbcDriverClassName,
String connectionUrl,
String username,
String password,
Map parameters)
Creates the database specified by the given parameters.
|
protected String |
createDeleteSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] primaryKeys,
org.apache.commons.beanutils.DynaBean bean)
Creates the SQL for deleting an object of the given type.
|
protected String |
createInsertSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean bean)
Creates the SQL for inserting an object of the given type.
|
void |
createModel(Connection connection,
Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createModel(Connection connection,
Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createModel(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createModel(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
protected ModelBasedResultSetIterator |
createResultSetIterator(Database model,
ResultSet resultSet,
Table[] queryHints)
Creates an iterator over the given result set.
|
protected String |
createSelectLastInsertIdSql(Database model,
SqlDynaClass dynaClass)
Creates the SQL for querying for the id generated by the last insert of an object of the given type.
|
void |
createTables(Connection connection,
Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Connection connection,
Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
protected String |
createUpdateSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] primaryKeys,
SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean bean)
Creates the SQL for updating an object of the given type.
|
protected String |
createUpdateSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] primaryKeys,
SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean oldBean,
org.apache.commons.beanutils.DynaBean newBean)
Creates the SQL for updating an object of the given type.
|
void |
delete(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Deletes the row which maps to the given bean from the database.
|
void |
delete(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Deletes the given bean from the database, assuming the primary key values are specified.
|
void |
dropDatabase(String jdbcDriverClassName,
String connectionUrl,
String username,
String password)
Drops the database specified by the given parameters.
|
void |
dropModel(Connection connection,
Database model,
boolean continueOnError)
Drops the given model.
|
void |
dropModel(Database model,
boolean continueOnError)
Drops the given model using the default database connection.
|
void |
dropTable(Connection connection,
Database model,
Table table,
boolean continueOnError)
Drops the specified table and all foreign keys pointing to it.
|
void |
dropTable(Database model,
Table table,
boolean continueOnError)
Drops the specified table and all foreign keys pointing to it.
|
void |
dropTables(Connection connection,
Database model,
boolean continueOnError)
Drops the given model.
|
void |
dropTables(Database model,
boolean continueOnError)
Drops the given model using the default database connection.
|
int |
evaluateBatch(Connection connection,
String sql,
boolean continueOnError)
Executes a series of sql statements which must be seperated by the delimiter
configured as
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform. |
int |
evaluateBatch(String sql,
boolean continueOnError)
Executes a series of sql statements which must be seperated by the delimiter
configured as
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform. |
boolean |
exists(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Determines whether the given dyna bean is stored in the database.
|
boolean |
exists(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Determines whether the given dyna bean is stored in the database.
|
protected Object |
extractColumnValue(ResultSet resultSet,
String columnName,
int columnIdx,
int jdbcType)
This is the core method to retrieve a value for a column from a result set.
|
List |
fetch(Database model,
String sql)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
protected ForeignKey |
findChangedForeignKey(Database currentModel,
ForeignKeyChange change)
Finds the foreign key changed by the change object in the given model.
|
protected Index |
findChangedIndex(Database currentModel,
IndexChange change)
Finds the index changed by the change object in the given model.
|
protected Table |
findChangedTable(Database currentModel,
TableChange change)
Finds the table changed by the change object in the given model.
|
String |
getAlterModelSql(Database currentModel,
Database desiredModel)
Returns the SQL for altering the given current model so that it match the desired model.
|
String |
getAlterModelSql(Database currentModel,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the given current model so that it match the desired model.
|
String |
getAlterTablesSql(Connection connection,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(String catalog,
String schema,
String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
List |
getChanges(Database currentModel,
Database desiredModel)
Returns the necessary changes to apply to the current database to make it the desired one.
|
String |
getCreateModelSql(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getCreateModelSql(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getCreateTablesSql(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getCreateTablesSql(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getDeleteSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for deleting the given bean from the database.
|
String |
getDropModelSql(Database model)
Returns the SQL for dropping the given model.
|
String |
getDropTableSql(Database model,
Table table,
boolean continueOnError)
Returns the SQL for dropping the given table and all foreign keys pointing to it.
|
String |
getDropTablesSql(Database model,
boolean continueOnError)
Returns the SQL for dropping the given model.
|
String |
getInsertSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for inserting the given bean.
|
protected org.apache.commons.logging.Log |
getLog()
Returns the log for this platform.
|
protected ModelComparator |
getModelComparator()
Returns the model comparator to be used for this platform.
|
JdbcModelReader |
getModelReader()
Returns the model reader (which reads a database model from a live database) for this platform.
|
protected Object |
getObjectFromResultSet(ResultSet resultSet,
Column column,
int idx)
Helper method for retrieving the value for a column from the given result set
using the type code of the column.
|
protected Object |
getObjectFromResultSet(ResultSet resultSet,
String columnName,
Table table)
Helper method esp.
|
PlatformInfo |
getPlatformInfo()
Returns the info object for this platform.
|
SqlBuilder |
getSqlBuilder()
Returns the sql builder for the this platform.
|
protected TableDefinitionChangesPredicate |
getTableDefinitionChangesPredicate()
Returns the predicate that defines which changes are supported by the platform.
|
protected Table |
getTemporaryTableFor(Table targetTable)
Creates a temporary table object that corresponds to the given table.
|
String |
getUpdateSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for updating the given bean in the database.
|
String |
getUpdateSql(Database model,
org.apache.commons.beanutils.DynaBean oldDynaBean,
org.apache.commons.beanutils.DynaBean newDynaBean)
Returns the sql for updating the given bean in the database.
|
void |
insert(Connection connection,
Database model,
Collection dynaBeans)
Inserts the given beans.
|
void |
insert(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Inserts the bean.
|
void |
insert(Database model,
Collection dynaBeans)
Inserts the given beans in the database, assuming the primary key values are specified.
|
void |
insert(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Inserts the given DynaBean in the database, assuming the primary key values are specified.
|
boolean |
isAddIdentityUsingAlterTableOn()
Returns true if identity column has to be added at the end of a load
using ALTER TABLE (only supported by GemFireXD for now)
|
boolean |
isDefaultOnDeleteActionUsedIfUnsupported()
Determines whether the default action for ON DELETE is used if the specified one is not supported by the platform.
|
boolean |
isDefaultOnUpdateActionUsedIfUnsupported()
Determines whether the default action for ON UPDATE is used if the specified one is not supported by the platform.
|
boolean |
isDelimitedIdentifierModeOn()
Determines whether delimited identifiers are used or normal SQL92 identifiers
(which may only contain alphanumerical characters and the underscore, must start
with a letter and cannot be a reserved keyword).
|
boolean |
isForeignKeysSorted()
Determines whether foreign keys of a table read from a live database
are alphabetically sorted.
|
boolean |
isIdentityOverrideOn()
Determines whether SQL insert statements can specify values for identity columns.
|
boolean |
isScriptModeOn()
Determines whether script mode is on.
|
boolean |
isSqlCommentsOn()
Determines whether SQL comments are generated.
|
protected void |
logWarnings(Connection connection)
Logs any warnings associated to the given connection.
|
protected void |
postprocessModelFromDatabase(Database model)
Allows the platform to postprocess the model just read from the database.
|
void |
processChange(Database currentModel,
CreationParameters params,
AddColumnChange change)
Processes a change representing the addition of a column.
|
void |
processChange(Database currentModel,
CreationParameters params,
AddForeignKeyChange change)
Processes a change representing the addition of a foreign key.
|
void |
processChange(Database currentModel,
CreationParameters params,
AddIndexChange change)
Processes a change representing the addition of an index.
|
void |
processChange(Database currentModel,
CreationParameters params,
AddPrimaryKeyChange change)
Processes a change representing the addition of a primary key.
|
void |
processChange(Database currentModel,
CreationParameters params,
AddTableChange change)
Processes a change representing the addition of a table.
|
void |
processChange(Database currentModel,
CreationParameters params,
RecreateTableChange change)
Processes a change representing the recreation of a table.
|
void |
processChange(Database currentModel,
CreationParameters params,
RemoveForeignKeyChange change)
Processes a change representing the removal of a foreign key.
|
void |
processChange(Database currentModel,
CreationParameters params,
RemoveIndexChange change)
Processes a change representing the removal of an index.
|
void |
processChange(Database currentModel,
CreationParameters params,
RemoveTableChange change)
Processes a change representing the removal of a table.
|
protected Database |
processChanges(Database model,
Collection changes,
CreationParameters params)
Processes the given changes in the specified order.
|
Iterator |
query(Database model,
String sql)
Performs the given SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Collection parameters)
Performs the given parameterized SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Collection parameters,
Table[] queryHints)
Performs the given parameterized SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Table[] queryHints)
Performs the given SQL query returning an iterator over the results.
|
Database |
readModelFromDatabase(Connection connection,
String name)
Reads the database model from the live database to which the given connection is pointing.
|
Database |
readModelFromDatabase(Connection connection,
String name,
String catalog,
String schema,
String[] tableTypes)
Reads the database model from the live database to which the given connection is pointing.
|
Database |
readModelFromDatabase(String name)
Reads the database model from the live database as specified by the data source set for
this platform.
|
Database |
readModelFromDatabase(String name,
String catalog,
String schema,
String[] tableTypes)
Reads the database model from the live database as specified by the data source set for
this platform.
|
void |
setAddIdentityUsingAlterTable(boolean v)
Set the flag for
Platform.isAddIdentityUsingAlterTableOn(). |
void |
setDefaultOnDeleteActionUsedIfUnsupported(boolean useDefault)
Specifies whether the default action for ON DELETE shall be used if the specified one is not supported by the platform.
|
void |
setDefaultOnUpdateActionUsedIfUnsupported(boolean useDefault)
Specifies whether the default action for ON UPDATE shall be used if the specified one is not supported by the platform.
|
void |
setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
Specifies whether delimited identifiers are used or normal SQL92 identifiers.
|
void |
setForeignKeysSorted(boolean foreignKeysSorted)
Specifies whether foreign keys read from a live database, shall be
alphabetically sorted.
|
void |
setIdentityOverrideOn(boolean identityOverrideOn)
Specifies whether SQL insert statements can specify values for identity columns.
|
protected void |
setModelReader(JdbcModelReader modelReader)
Sets the model reader for this platform.
|
protected void |
setObject(PreparedStatement statement,
int sqlIndex,
org.apache.commons.beanutils.DynaBean dynaBean,
SqlDynaProperty property)
Sets a parameter of the prepared statement based on the type of the column of the property.
|
void |
setScriptModeOn(boolean scriptModeOn)
Specifies whether script mode is on.
|
protected void |
setSqlBuilder(SqlBuilder builder)
Sets the sql builder for this platform.
|
void |
setSqlCommentsOn(boolean sqlCommentsOn)
Specifies whether SQL comments shall be generated.
|
protected void |
setStatementParameterValue(PreparedStatement statement,
int sqlIndex,
int typeCode,
Object value)
This is the core method to set the parameter of a prepared statement to a given value.
|
void |
shutdownDatabase()
Performs a shutdown at the database.
|
void |
shutdownDatabase(Connection connection)
Performs a shutdown at the database.
|
protected List |
sortChanges(List changes)
Sorts the changes so that they can be executed by the database.
|
void |
store(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Stores the given bean in the database, inserting it if there is no primary key
otherwise the bean is updated in the database.
|
void |
store(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Stores the given bean in the database, inserting it if there is no primary key
otherwise the bean is updated in the database.
|
protected HashMap |
toColumnValues(SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean bean)
Derives the column values for the given dyna properties from the dyna bean.
|
void |
update(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Updates the row which maps to the given bean.
|
void |
update(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean oldDynaBean,
org.apache.commons.beanutils.DynaBean newDynaBean)
Updates the row identified by the given
oldDynaBean in the database with the
values in newDynaBean. |
void |
update(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Updates the given bean in the database, assuming the primary key values are specified.
|
void |
update(Database model,
org.apache.commons.beanutils.DynaBean oldDynaBean,
org.apache.commons.beanutils.DynaBean newDynaBean)
Updates the row identified by the given
oldDynaBean in the database with the
values in newDynaBean. |
String |
writeAllDDLs(boolean exportAll)
Export all DDLs executed in the system as SQL strings.
|
protected void |
writeAllDDLs(Connection conn,
Writer writer,
boolean exportAll) |
borrowConnection, closeStatement, getDataSource, getIsolationLevel, getPassword, getUsername, returnConnection, setDataSource, setIsolationLevel, setPassword, setUsernameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitborrowConnection, getDataSource, getIsolationLevel, getName, getPassword, getUsername, returnConnection, setDataSource, setIsolationLevel, setPassword, setUsernameprotected static final String MODEL_DEFAULT_NAME
public SqlBuilder getSqlBuilder()
getSqlBuilder in interface Platformprotected void setSqlBuilder(SqlBuilder builder)
builder - The sql builderpublic JdbcModelReader getModelReader()
getModelReader in interface Platformprotected void setModelReader(JdbcModelReader modelReader)
modelReader - The model readerpublic PlatformInfo getPlatformInfo()
getPlatformInfo in interface Platformpublic boolean isScriptModeOn()
isScriptModeOn in interface Platformtrue if script mode is onpublic void setScriptModeOn(boolean scriptModeOn)
setScriptModeOn in interface PlatformscriptModeOn - true if script mode is onpublic boolean isSqlCommentsOn()
isSqlCommentsOn in interface Platformtrue if SQL comments shall be generatedpublic void setSqlCommentsOn(boolean sqlCommentsOn)
setSqlCommentsOn in interface PlatformsqlCommentsOn - true if SQL comments shall be generatedpublic boolean isDelimitedIdentifierModeOn()
isDelimitedIdentifierModeOn in interface Platformtrue if delimited identifiers are usedpublic void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
setDelimitedIdentifierModeOn in interface PlatformdelimitedIdentifierModeOn - true if delimited identifiers shall be usedpublic boolean isIdentityOverrideOn()
PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the
insert methods will ignore values for identity columns.isIdentityOverrideOn in interface Platformtrue if identity override is enabled (the default)public void setIdentityOverrideOn(boolean identityOverrideOn)
PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the
insert methods will ignore values for identity columns.setIdentityOverrideOn in interface PlatformidentityOverrideOn - true if identity override is enabled (the default)public boolean isForeignKeysSorted()
isForeignKeysSorted in interface Platformtrue if read foreign keys are sortedpublic void setForeignKeysSorted(boolean foreignKeysSorted)
setForeignKeysSorted in interface PlatformforeignKeysSorted - true if read foreign keys shall be sortedpublic boolean isDefaultOnUpdateActionUsedIfUnsupported()
false, then an exception will be thrown if the action is not supported. By default, this
is set to true meaning that the default action would be used.isDefaultOnUpdateActionUsedIfUnsupported in interface Platformtrue if the default action is usedpublic void setDefaultOnUpdateActionUsedIfUnsupported(boolean useDefault)
false, then an exception will be thrown if the action is not supported. By default, this
is set to true meaning that the default action would be used.setDefaultOnUpdateActionUsedIfUnsupported in interface PlatformuseDefault - If true then the default action will be usedpublic boolean isDefaultOnDeleteActionUsedIfUnsupported()
false, then an exception will be thrown if the action is not supported. By default, this
is set to true meaning that the default action would be used.isDefaultOnDeleteActionUsedIfUnsupported in interface Platformtrue if the default action is usedpublic void setDefaultOnDeleteActionUsedIfUnsupported(boolean useDefault)
false, then an exception will be thrown if the action is not supported. By default, this
is set to true meaning that the default action would be used.setDefaultOnDeleteActionUsedIfUnsupported in interface PlatformuseDefault - If true then the default action will be usedprotected org.apache.commons.logging.Log getLog()
protected void logWarnings(Connection connection) throws SQLException
connection - The open connectionSQLExceptionpublic int evaluateBatch(String sql, boolean continueOnError) throws DatabaseOperationException
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform.evaluateBatch in interface Platformsql - The sql statements to executecontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DatabaseOperationException
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform.
TODO: consider outputting a collection of String or some kind of statement
object from the SqlBuilder instead of having to parse strings hereevaluateBatch in interface Platformconnection - The connection to the databasesql - The sql statements to executecontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void shutdownDatabase()
throws DatabaseOperationException
shutdownDatabase in interface PlatformDatabaseOperationExceptionpublic void shutdownDatabase(Connection connection) throws DatabaseOperationException
shutdownDatabase in interface Platformconnection - The connection to the databaseDatabaseOperationExceptionpublic void createDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters) throws DatabaseOperationException, UnsupportedOperationException
Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection.createDatabase in interface PlatformjdbcDriverClassName - The jdbc driver class nameconnectionUrl - The url to connect to the database if it were already createdusername - The username for creating the databasepassword - The password for creating the databaseparameters - Additional parameters relevant to database creation (which are platform specific)DatabaseOperationExceptionUnsupportedOperationExceptionpublic void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password) throws DatabaseOperationException, UnsupportedOperationException
Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection.dropDatabase in interface PlatformjdbcDriverClassName - The jdbc driver class nameconnectionUrl - The url to connect to the databaseusername - The username for creating the databasepassword - The password for creating the databaseDatabaseOperationExceptionUnsupportedOperationExceptionpublic void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformconnection - The connection to the databasemodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformconnection - The connection to the databasemodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredpublic String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredpublic void createModel(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createModel in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createModel(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createModel in interface Platformconnection - The connection to the databasemodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createModel(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createModel in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createModel(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createModel in interface Platformconnection - The connection to the databasemodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getCreateModelSql(Database model, boolean dropTablesFirst, boolean continueOnError)
getCreateModelSql in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredpublic String getCreateModelSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
getCreateModelSql in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredprotected ModelComparator getModelComparator()
protected TableDefinitionChangesPredicate getTableDefinitionChangesPredicate()
public List getChanges(Database currentModel, Database desiredModel)
getChanges in interface PlatformcurrentModel - The current modeldesiredModel - The desired modelprotected List sortChanges(List changes)
changes - The original changespublic void alterTables(Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface PlatformdesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface PlatformdesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(Connection connection, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(Connection connection, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface PlatformdesiredModel - The desired database schemaDatabaseOperationExceptionpublic String getAlterTablesSql(Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface PlatformdesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaDatabaseOperationExceptionpublic String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic String getAlterModelSql(Database currentModel, Database desiredModel) throws DatabaseOperationException
getAlterModelSql in interface PlatformcurrentModel - The current database modeldesiredModel - The desired database modelDatabaseOperationExceptionpublic String getAlterModelSql(Database currentModel, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterModelSql in interface PlatformcurrentModel - The current database modeldesiredModel - The desired database modelparams - The parameters used in the creation of tables etc.DatabaseOperationExceptionpublic void alterModel(Database currentModel, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterModel in interface PlatformcurrentModel - The current database modeldesiredModel - The desired database modelcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterModel(Database currentModel, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterModel in interface PlatformcurrentModel - The current database modeldesiredModel - The desired database modelparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterModel(Connection connection, Database currentModel, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterModel in interface Platformconnection - A connection to the existing database that shall be modifiedcurrentModel - The current database modeldesiredModel - The desired database modelcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void alterModel(Connection connection, Database currentModel, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterModel in interface Platformconnection - A connection to the existing database that shall be modifiedcurrentModel - The current database modeldesiredModel - The desired database modelparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic void dropTable(Connection connection, Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable in interface Platformconnection - The connection to the databasemodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void dropTable(Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable in interface Platformmodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getDropTableSql(Database model, Table table, boolean continueOnError)
getDropTableSql in interface Platformmodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredpublic void dropTables(Database model, boolean continueOnError) throws DatabaseOperationException
dropTables in interface Platformmodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void dropTables(Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException
dropTables in interface Platformconnection - The connection to the databasemodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getDropTablesSql(Database model, boolean continueOnError)
getDropTablesSql in interface Platformmodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredpublic void dropModel(Database model, boolean continueOnError) throws DatabaseOperationException
dropModel in interface Platformmodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void dropModel(Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException
dropModel in interface Platformconnection - The connection to the databasemodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getDropModelSql(Database model)
getDropModelSql in interface Platformmodel - The database modelprotected Database processChanges(Database model, Collection changes, CreationParameters params) throws IOException, DdlUtilsException
processChange methods) defined in
the concrete sql builder for each change, and invokes it.model - The database model; this object is not going to be changed by this methodchanges - The changesparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedIOExceptionDdlUtilsExceptionprotected Table findChangedTable(Database currentModel, TableChange change) throws ModelException
currentModel - The model to find the table inchange - The table changeModelException - If the table could not be foundprotected Index findChangedIndex(Database currentModel, IndexChange change) throws ModelException
currentModel - The model to find the index inchange - The index changeModelException - If the index could not be foundprotected ForeignKey findChangedForeignKey(Database currentModel, ForeignKeyChange change) throws ModelException
currentModel - The model to find the foreign key inchange - The foreign key changeModelException - If the foreign key could not be foundpublic void processChange(Database currentModel, CreationParameters params, AddTableChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionpublic void processChange(Database currentModel, CreationParameters params, RemoveTableChange change) throws IOException, ModelException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionModelExceptionpublic void processChange(Database currentModel, CreationParameters params, AddForeignKeyChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionpublic void processChange(Database currentModel, CreationParameters params, RemoveForeignKeyChange change) throws IOException, ModelException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionModelExceptionpublic void processChange(Database currentModel, CreationParameters params, AddIndexChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionpublic void processChange(Database currentModel, CreationParameters params, RemoveIndexChange change) throws IOException, ModelException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionModelExceptionpublic void processChange(Database currentModel, CreationParameters params, AddColumnChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionpublic void processChange(Database currentModel, CreationParameters params, AddPrimaryKeyChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionpublic void processChange(Database currentModel, CreationParameters params, RecreateTableChange change) throws IOException
currentModel - The current database schemaparams - The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange - The change objectIOExceptionprotected Table getTemporaryTableFor(Table targetTable)
targetTable - The target tablepublic Iterator query(Database model, String sql) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performDatabaseOperationExceptionpublic Iterator query(Database model, String sql, Collection parameters) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performparameters - The query parameter valuesDatabaseOperationExceptionpublic Iterator query(Database model, String sql, Table[] queryHints) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performparameters - The query parameter valuesqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.fetch in interface Platformmodel - The database model to usesql - The sql queryDatabaseOperationExceptionpublic List fetch(Database model, String sql, Table[] queryHints) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.fetch in interface Platformmodel - The database model to usesql - The sql queryqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql, int start, int end) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.
Also, the two int parameters specify which rows of the result set to use.
If there are more rows than desired, they will be ignored (and not read
from the database).fetch in interface Platformmodel - The database model to usesql - The sql querystart - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Table[] queryHints, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Table[]) method all
beans will be materialized and the connection will be closed before
returning the beans. Also, the two int parameters specify which rows of
the result set to use. If there are more rows than desired, they will be
ignored (and not read from the database).fetch in interface Platformmodel - The database model to usesql - The sql queryqueryHints - The tables that are queried (optional)start - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters) throws DatabaseOperationException
Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans.fetch in interface Platformmodel - The database model to usesql - The parameterized queryparameters - The parameter valuesDatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Collection) method all
beans will be materialized and the connection will be closed before returning
the beans. Also, the two int parameters specify which rows of the result set
to use. If there are more rows than desired, they will be ignored (and not
read from the database).fetch in interface Platformmodel - The database model to usesql - The parameterized sql queryparameters - The parameter valuesstart - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException
Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans.fetch in interface Platformmodel - The database model to usesql - The parameterized queryparameters - The parameter valuesqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, Table[] queryHints, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Collection, Table[])
method all beans will be materialized and the connection will be closed
before returning the beans. Also, the two int parameters specify which
rows of the result set to use. If there are more rows than desired, they
will be ignored (and not read from the database).fetch in interface Platformmodel - The database model to usesql - The parameterized sql queryparameters - The parameter valuesqueryHints - The tables that are queried (optional)start - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionprotected String createInsertSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeproperties - The properties to writebean - Optionally the concrete bean to insertprotected String createSelectLastInsertIdSql(Database model, SqlDynaClass dynaClass)
model - The database modeldynaClass - The typenull if the database does not
support thispublic String getInsertSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getInsertSql in interface Platformmodel - The database model to usedynaBean - The beanpublic void insert(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic void insert(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert in interface Platformmodel - The database model to usedynaBean - The bean to insertDatabaseOperationExceptionpublic void insert(Connection connection, Database model, Collection dynaBeans) throws DatabaseOperationException
insert in interface Platformconnection - The database connectionmodel - The database model to usedynaBeans - The beansDatabaseOperationExceptionpublic void insert(Database model, Collection dynaBeans) throws DatabaseOperationException
insert in interface Platformmodel - The database model to usedynaBeans - The beans to insertDatabaseOperationExceptionprotected void beforeInsert(Connection connection, Table table) throws SQLException
connection - The connection used for the insertiontable - The table that the rows are inserted intoSQLExceptionprotected void afterInsert(Connection connection, Table table) throws SQLException
connection - The connection used for the insertiontable - The table that the rows have been inserted intoSQLExceptionprotected String createUpdateSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeprimaryKeys - The primary keysproperties - The properties to writebean - Optionally the concrete bean to updateprotected String createUpdateSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean oldBean, org.apache.commons.beanutils.DynaBean newBean)
model - The database modeldynaClass - The typeprimaryKeys - The primary keysproperties - The properties to writeoldBean - Contains column values to identify the rows to update (i.e. for the WHERE clause)newBean - Contains the new column values to writepublic String getUpdateSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getUpdateSql in interface Platformmodel - The database model to usedynaBean - The beanpublic String getUpdateSql(Database model, org.apache.commons.beanutils.DynaBean oldDynaBean, org.apache.commons.beanutils.DynaBean newDynaBean)
getUpdateSql in interface Platformmodel - The database model to useoldDynaBean - The bean identifying the row to updatenewDynaBean - The bean containing the new valuespublic void update(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic void update(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update in interface Platformmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic void update(Connection connection, Database model, org.apache.commons.beanutils.DynaBean oldDynaBean, org.apache.commons.beanutils.DynaBean newDynaBean) throws DatabaseOperationException
oldDynaBean in the database with the
values in newDynaBean. This method can be used to update primary key columns.update in interface Platformconnection - The database connectionmodel - The database model to useoldDynaBean - The bean identifying the row (which means the primary key fields need to be specified)newDynaBean - The bean containing the new dataDatabaseOperationExceptionpublic void update(Database model, org.apache.commons.beanutils.DynaBean oldDynaBean, org.apache.commons.beanutils.DynaBean newDynaBean) throws DatabaseOperationException
oldDynaBean in the database with the
values in newDynaBean. This method can be used to update primary key columns.update in interface Platformmodel - The database model to useoldDynaBean - The bean identifying the row (which means the primary key fields need to be specified)newDynaBean - The bean containing the new dataDatabaseOperationExceptionprotected void beforeUpdate(Connection connection, Table table) throws SQLException
connection - The connection used for the updatetable - The table that the rows are updateed intoSQLExceptionprotected void afterUpdate(Connection connection, Table table) throws SQLException
connection - The connection used for the updatetable - The table that the rows have been updateed intoSQLExceptionpublic boolean exists(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
public boolean exists(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean)
public void store(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
store in interface Platformmodel - The database model to usedynaBean - The bean to storeDatabaseOperationExceptionpublic void store(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
store in interface Platformconnection - The connectionmodel - The database model to usedynaBean - The bean to storeDatabaseOperationExceptionprotected String createDeleteSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeprimaryKeys - The primary keysbean - Optionally the concrete bean to updatepublic String getDeleteSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getDeleteSql in interface Platformmodel - The database model to usedynaBean - The beanpublic void delete(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete in interface Platformmodel - The database model to usedynaBean - The bean to deleteDatabaseOperationExceptionpublic void delete(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic Database readModelFromDatabase(String name) throws DatabaseOperationException
readModelFromDatabase in interface Platformname - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name) throws DatabaseOperationException
readModelFromDatabase in interface Platformconnection - The connection to the databasename - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase in interface Platformname - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughcatalog - The catalog to access in the database; use null for the default valueschema - The schema to access in the database; use null for the default valuetableTypes - The table types to process; use null or an empty list for the default onesDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase in interface Platformconnection - The connection to the databasename - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughcatalog - The catalog to access in the database; use null for the default valueschema - The schema to access in the database; use null for the default valuetableTypes - The table types to process; use null or an empty list for the default onesDatabaseOperationException - If an error occurred during reading the modelprotected void postprocessModelFromDatabase(Database model)
model - The modelprotected HashMap toColumnValues(SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
properties - The propertiesbean - The beanprotected void setObject(PreparedStatement statement, int sqlIndex, org.apache.commons.beanutils.DynaBean dynaBean, SqlDynaProperty property) throws SQLException
statement - The statementsqlIndex - The index of the parameter to set in the statementdynaBean - The bean of which to take the valueproperty - The property of the bean, which also defines the corresponding columnSQLExceptionprotected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int typeCode, Object value) throws SQLException
statement - The statementsqlIndex - The parameter indextypeCode - The JDBC type codevalue - The valueSQLException - If an error occurred while setting the parameter valueprotected Object getObjectFromResultSet(ResultSet resultSet, String columnName, Table table) throws SQLException
ModelBasedResultSetIterator class that retrieves
the value for a column from the given result set. If a table was specified,
and it contains the column, then the jdbc type defined for the column is used for extracting
the value, otherwise the object directly retrieved from the result set is returned.ModelBasedResultSetIterator class
so that concrete platforms can modify its behavior.resultSet - The result setcolumnName - The name of the columntable - The tableSQLExceptionprotected Object getObjectFromResultSet(ResultSet resultSet, Column column, int idx) throws SQLException
resultSet - The result setcolumn - The columnidx - The value's index in the result set (starting from 1)SQLExceptionprotected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType) throws SQLException
resultSet - The result set to extract the value fromcolumnName - The name of the column; can be null in which case the
columnIdx will be used insteadcolumnIdx - The index of the column's value in the result set; is only used if
columnName is nulljdbcType - The jdbc type to extractSQLException - If an error occurred while accessing the result setprotected ModelBasedResultSetIterator createResultSetIterator(Database model, ResultSet resultSet, Table[] queryHints)
model - The database modelresultSet - The result set to iterate overqueryHints - The tables that were queried in the query that produced the
given result set (optional)public final boolean isAddIdentityUsingAlterTableOn()
isAddIdentityUsingAlterTableOn in interface Platformpublic final void setAddIdentityUsingAlterTable(boolean v)
Platform.isAddIdentityUsingAlterTableOn().setAddIdentityUsingAlterTable in interface Platformpublic String writeAllDDLs(boolean exportAll) throws DatabaseOperationException
writeAllDDLs in interface PlatformexportAll - if true then also export all database objects including
jars/listeners etcDatabaseOperationExceptionprotected void writeAllDDLs(Connection conn, Writer writer, boolean exportAll) throws SQLException, IOException
SQLExceptionIOExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.