Interface Platform
- All Known Implementing Classes:
AxionPlatform
,CloudscapePlatform
,Db2Platform
,Db2v8Platform
,DerbyPlatform
,FirebirdPlatform
,HsqlDbPlatform
,InterbasePlatform
,MaxDbPlatform
,MckoiPlatform
,MSSqlPlatform
,MySql50Platform
,MySqlPlatform
,Oracle10Platform
,Oracle8Platform
,Oracle9Platform
,PlatformImplBase
,PostgreSqlPlatform
,SapDbPlatform
,SybaseASE15Platform
,SybasePlatform
public interface Platform
A platform encapsulates the database-related functionality such as performing queries
and manipulations. It also contains an sql builder that is specific to this platform.
- Version:
- $Revision: 231110 $
-
Method Summary
Modifier and TypeMethodDescriptionvoid
alterTables
(Database desiredDb, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(Database desiredDb, CreationParameters params, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(String catalog, String schema, String[] tableTypes, Database desiredDb, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(Connection connection, Database desiredDb, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(Connection connection, Database desiredDb, 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 desiredDb, boolean continueOnError) Alters the database schema so that it match the given model.void
alterTables
(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError) Alters the database schema so that it match the given model.Returns a (new) JDBC connection from the data source.void
createDatabase
(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters) Creates the database specified by the given parameters.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.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
Deletes the given bean from the database, assuming the primary key values are specified.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
dropDatabase
(String jdbcDriverClassName, String connectionUrl, String username, String password) Drops the database specified by the given parameters.void
Drops the specified table and all foreign keys pointing to it.void
dropTable
(Connection connection, Database model, Table table, boolean continueOnError) Drops the specified table and all foreign keys pointing to it.void
dropTables
(Database model, boolean continueOnError) Drops the tables defined in the given database.void
dropTables
(Connection connection, Database model, boolean continueOnError) Drops the tables defined in the given database.int
evaluateBatch
(String sql, boolean continueOnError) Executes a series of sql statements which must be seperated by the delimiter configured asPlatformInfo.getSqlCommandDelimiter()
of the info object of this platform.int
evaluateBatch
(Connection connection, String sql, boolean continueOnError) Executes a series of sql statements which must be seperated by the delimiter configured asPlatformInfo.getSqlCommandDelimiter()
of the info object of this platform.Queries for a list of dyna beans representing rows of the given query.Queries for a list of dyna beans representing rows of the given query.Queries for a list of dyna beans representing rows of the given query.Queries for a list of dyna beans representing rows of the given query.fetch
(Database model, String sql, Collection parameters) Queries for a list of dyna beans representing rows of the given query.fetch
(Database model, String sql, Collection parameters, int start, int end) Queries for a list of dyna beans representing rows of the given query.fetch
(Database model, String sql, Collection parameters, Table[] queryHints) Queries for a list of dyna beans representing rows of the given query.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.getAlterTablesSql
(Database desiredDb) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Database desiredDb, CreationParameters params) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(String catalog, String schema, String[] tableTypes, Database desiredDb) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Connection connection, Database desiredDb) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Connection connection, Database desiredDb, CreationParameters params) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params) Returns the SQL for altering the database schema so that it match the given model.getCreateTablesSql
(Database model, boolean dropTablesFirst, boolean continueOnError) Returns the SQL for creating the tables defined in the database model.getCreateTablesSql
(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) Returns the SQL for creating the tables defined in the database model.Returns the data source that this platform uses to access the database.getDeleteSql
(Database model, org.apache.commons.beanutils.DynaBean dynaBean) Returns the sql for deleting the given bean from the database.getDropTableSql
(Database model, Table table, boolean continueOnError) Returns the SQL for dropping the given table and all foreign keys pointing to it.getDropTablesSql
(Database model, boolean continueOnError) Returns the SQL for dropping the tables defined in the given database.getInsertSql
(Database model, org.apache.commons.beanutils.DynaBean dynaBean) Returns the sql for inserting the given bean.Returns the model reader (which reads a database model from a live database) for this platform.getName()
Returns the name of the database that this platform is for.Returns the password that this platform shall use to access the database.Returns the info object for this platform.Returns the sql builder for the this platform.getUpdateSql
(Database model, org.apache.commons.beanutils.DynaBean dynaBean) Returns the sql for updating the given bean in the database.Returns the username that this platform shall use to access the database.void
insert
(Database model, Collection dynaBeans) Inserts the given beans in the database, assuming the primary key values are specified.void
Inserts the given DynaBean in the database, assuming the primary key values are specified.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.boolean
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
Determines whether foreign keys of a table read from a live database are alphabetically sorted.boolean
Determines whether SQL insert statements can specify values for identity columns.boolean
Determines whether script mode is on.boolean
Determines whether SQL comments are generated.Performs the given SQL query returning an iterator over the results.Performs the given SQL query returning an iterator over the results.query
(Database model, String sql, Collection parameters) Performs the given parameterized SQL query returning an iterator over the results.query
(Database model, String sql, Collection parameters, Table[] queryHints) Performs the given parameterized SQL query returning an iterator over the results.readModelFromDatabase
(String name) Reads the database model from the live database as specified by the data source set for this platform.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.readModelFromDatabase
(Connection connection, String name) Reads the database model from the live database to which the given connection is pointing.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.void
returnConnection
(Connection connection) Closes the given JDBC connection (returns it back to the pool if the datasource is poolable).void
setDataSource
(DataSource dataSource) Sets the data source that this platform shall use to access the database.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.void
setPassword
(String password) Sets the password that this platform shall use to access the database.void
setScriptModeOn
(boolean scriptModeOn) Specifies whether script mode is on.void
setSqlCommentsOn
(boolean sqlCommentsOn) Specifies whether SQL comments shall be generated.void
setUsername
(String username) Sets the username that this platform shall use to access the database.void
Performs a shutdown at the database.void
shutdownDatabase
(Connection connection) Performs a shutdown at the database.void
Stores the given bean in the database, inserting it if there is no primary key otherwise the bean is updated in the database.void
Updates the given bean in the database, assuming the primary key values are specified.void
update
(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) Updates the row which maps to the given bean.
-
Method Details
-
getName
String getName()Returns the name of the database that this platform is for.- Returns:
- The name
-
getPlatformInfo
PlatformInfo getPlatformInfo()Returns the info object for this platform.- Returns:
- The info object
-
getSqlBuilder
SqlBuilder getSqlBuilder()Returns the sql builder for the this platform.- Returns:
- The sql builder
-
getModelReader
JdbcModelReader getModelReader()Returns the model reader (which reads a database model from a live database) for this platform.- Returns:
- The model reader
-
getDataSource
DataSource getDataSource()Returns the data source that this platform uses to access the database.- Returns:
- The data source
-
setDataSource
Sets the data source that this platform shall use to access the database.- Parameters:
dataSource
- The data source
-
getUsername
String getUsername()Returns the username that this platform shall use to access the database.- Returns:
- The username
-
setUsername
Sets the username that this platform shall use to access the database.- Parameters:
username
- The username
-
getPassword
String getPassword()Returns the password that this platform shall use to access the database.- Returns:
- The password
-
setPassword
Sets the password that this platform shall use to access the database.- Parameters:
password
- The password
-
isScriptModeOn
boolean isScriptModeOn()Determines whether script mode is on. This means that the generated SQL is not intended to be sent directly to the database but rather to be saved in a SQL script file. Per default, script mode is off.- Returns:
true
if script mode is on
-
setScriptModeOn
void setScriptModeOn(boolean scriptModeOn) Specifies whether script mode is on. This means that the generated SQL is not intended to be sent directly to the database but rather to be saved in a SQL script file.- Parameters:
scriptModeOn
-true
if script mode is on
-
isDelimitedIdentifierModeOn
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). Per default, delimited identifiers are not used- Returns:
true
if delimited identifiers are used
-
setDelimitedIdentifierModeOn
void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn) Specifies whether delimited identifiers are used or normal SQL92 identifiers.- Parameters:
delimitedIdentifierModeOn
-true
if delimited identifiers shall be used
-
isSqlCommentsOn
boolean isSqlCommentsOn()Determines whether SQL comments are generated.- Returns:
true
if SQL comments shall be generated
-
setSqlCommentsOn
void setSqlCommentsOn(boolean sqlCommentsOn) Specifies whether SQL comments shall be generated.- Parameters:
sqlCommentsOn
-true
if SQL comments shall be generated
-
isIdentityOverrideOn
boolean isIdentityOverrideOn()Determines whether SQL insert statements can specify values for identity columns. This setting is only relevant if the database supports it (PlatformInfo.isIdentityOverrideAllowed()
). If this is off, then theinsert
methods will ignore values for identity columns.- Returns:
true
if identity override is enabled (the default)
-
setIdentityOverrideOn
void setIdentityOverrideOn(boolean identityOverrideOn) Specifies whether SQL insert statements can specify values for identity columns. This setting is only relevant if the database supports it (PlatformInfo.isIdentityOverrideAllowed()
). If this is off, then theinsert
methods will ignore values for identity columns.- Parameters:
identityOverrideOn
-true
if identity override is enabled (the default)
-
isForeignKeysSorted
boolean isForeignKeysSorted()Determines whether foreign keys of a table read from a live database are alphabetically sorted.- Returns:
true
if read foreign keys are sorted
-
setForeignKeysSorted
void setForeignKeysSorted(boolean foreignKeysSorted) Specifies whether foreign keys read from a live database, shall be alphabetically sorted.- Parameters:
foreignKeysSorted
-true
if read foreign keys shall be sorted
-
borrowConnection
Returns a (new) JDBC connection from the data source.- Returns:
- The connection
- Throws:
DatabaseOperationException
-
returnConnection
Closes the given JDBC connection (returns it back to the pool if the datasource is poolable).- Parameters:
connection
- The connection
-
evaluateBatch
Executes a series of sql statements which must be seperated by the delimiter configured asPlatformInfo.getSqlCommandDelimiter()
of the info object of this platform.- Parameters:
sql
- The sql statements to executecontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The number of errors
- Throws:
DatabaseOperationException
-
evaluateBatch
int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DatabaseOperationException Executes a series of sql statements which must be seperated by the delimiter configured asPlatformInfo.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 here- Parameters:
connection
- The connection to the databasesql
- The sql statements to executecontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The number of errors
- Throws:
DatabaseOperationException
-
shutdownDatabase
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.- Throws:
DatabaseOperationException
-
shutdownDatabase
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.- Parameters:
connection
- The connection to the database- Throws:
DatabaseOperationException
-
createDatabase
void createDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters) throws DatabaseOperationException, UnsupportedOperationException Creates the database specified by the given parameters. Please note that this method does not use a data source set viasetDataSource(DataSource)
because it is not possible to retrieve the connection information from it without establishing a connection.
The given connection url is the url that you'd use to connect to the already-created database.
On some platforms, this method suppurts additional parameters. These are documented in the manual section for the individual platforms.- Parameters:
jdbcDriverClassName
- 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)- Throws:
DatabaseOperationException
UnsupportedOperationException
-
dropDatabase
void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password) throws DatabaseOperationException, UnsupportedOperationException Drops the database specified by the given parameters. Please note that this method does not use a data source set viasetDataSource(DataSource)
because it is not possible to retrieve the connection information from it without establishing a connection.- Parameters:
jdbcDriverClassName
- The jdbc driver class nameconnectionUrl
- The url to connect to the databaseusername
- The username for creating the databasepassword
- The password for creating the database- Throws:
DatabaseOperationException
UnsupportedOperationException
-
createTables
void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Parameters:
model
- The database modeldropTablesFirst
- Whether to drop the tables prior to creating them (anew)continueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
createTables
void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Parameters:
connection
- 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 occurred- Throws:
DatabaseOperationException
-
getCreateTablesSql
Returns the SQL for creating the tables defined in the database model.- Parameters:
model
- The database modeldropTablesFirst
- Whether to drop the tables prior to creating them (anew)continueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The SQL statements
-
createTables
void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Parameters:
model
- 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 occurred- Throws:
DatabaseOperationException
-
createTables
void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Parameters:
connection
- 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 occurred- Throws:
DatabaseOperationException
-
getCreateTablesSql
String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) Returns the SQL for creating the tables defined in the database model.- Parameters:
model
- 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 occurred- Returns:
- The SQL statements
-
alterTables
Alters the database schema so that it match the given model.- Parameters:
desiredDb
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
Returns the SQL for altering the database schema so that it match the given model.- Parameters:
desiredDb
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
desiredDb
- The desired database schemaparams
- The parameters used in the creationcontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(Database desiredDb, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
desiredDb
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(String catalog, String schema, String[] tableTypes, Database desiredDb, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
catalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredDb) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
catalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
catalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemaparams
- The parameters used in the creationcontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
catalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(Connection connection, Database desiredDb, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredDb
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(Connection connection, Database desiredDb) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredDb
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(Connection connection, Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredDb
- The desired database schemaparams
- The parameters used in the creationcontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(Connection connection, Database desiredDb, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredDb
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifiedcatalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifiedcatalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifiedcatalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemaparams
- The parameters used in the creationcontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredDb, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Parameters:
connection
- A connection to the existing database that shall be modifiedcatalog
- The catalog in the existing database to read (can be a pattern); usenull
for the platform-specific default valueschema
- The schema in the existing database to read (can be a pattern); usenull
for the platform-specific default valuetableTypes
- The table types to read from the existing database; usenull
or an empty array for the platform-specific default valuedesiredDb
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
dropTable
void dropTable(Database model, Table table, boolean continueOnError) throws DatabaseOperationException Drops the specified table and all foreign keys pointing to it.- Parameters:
model
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
getDropTableSql
Returns the SQL for dropping the given table and all foreign keys pointing to it.- Parameters:
model
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The SQL statements
-
dropTable
void dropTable(Connection connection, Database model, Table table, boolean continueOnError) throws DatabaseOperationException Drops the specified table and all foreign keys pointing to it.- Parameters:
connection
- The connection to the databasemodel
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
dropTables
Drops the tables defined in the given database.- Parameters:
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
getDropTablesSql
Returns the SQL for dropping the tables defined in the given database.- Parameters:
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The SQL statements
-
dropTables
void dropTables(Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException Drops the tables defined in the given database.- Parameters:
connection
- The connection to the databasemodel
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
query
Performs the given SQL query returning an iterator over the results.- Parameters:
model
- The database model to usesql
- The sql query to perform- Returns:
- An iterator for the dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
query
Performs the given parameterized SQL query returning an iterator over the results.- Parameters:
model
- The database model to usesql
- The sql query to performparameters
- The query parameter values- Returns:
- An iterator for the dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
query
Performs the given SQL query returning an iterator over the results.- Parameters:
model
- The database model to usesql
- The sql query to performqueryHints
- The tables that are queried (optional)- Returns:
- An iterator for the dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
query
Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException Performs the given parameterized SQL query returning an iterator over the results.- Parameters:
model
- The database model to usesql
- The sql query to performparameters
- The query parameter valuesqueryHints
- The tables that are queried (optional)- Returns:
- An iterator for the dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(Database, String)
method all beans will be materialized and the connection will be closed before returning the beans.- Parameters:
model
- The database model to usesql
- The sql query- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(Database, String, Collection)
method all beans will be materialized and the connection will be closed before returning the beans.- Parameters:
model
- The database model to usesql
- The parameterized queryparameters
- The parameter values- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(Database, String)
method all beans will be materialized and the connection will be closed before returning the beans.- Parameters:
model
- The database model to usesql
- The sql queryqueryHints
- The tables that are queried (optional)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
List fetch(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(Database, String, Collection)
method all beans will be materialized and the connection will be closed before returning the beans.- Parameters:
model
- The database model to usesql
- The parameterized queryparameters
- The parameter valuesqueryHints
- The tables that are queried (optional)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(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).- Parameters:
model
- 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)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
List fetch(Database model, String sql, Collection parameters, int start, int end) throws DatabaseOperationException Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(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).- Parameters:
model
- 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)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
List fetch(Database model, String sql, Table[] queryHints, int start, int end) throws DatabaseOperationException Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(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).- Parameters:
model
- 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)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
List fetch(Database model, String sql, Collection parameters, Table[] queryHints, int start, int end) throws DatabaseOperationException Queries for a list of dyna beans representing rows of the given query. In contrast to thequery(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).- Parameters:
model
- 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)- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
store
void store(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Stores the given bean in the database, inserting it if there is no primary key otherwise the bean is updated in the database.- Parameters:
model
- The database model to usedynaBean
- The bean to store- Throws:
DatabaseOperationException
-
getInsertSql
Returns the sql for inserting the given bean.- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The insert sql
-
insert
void insert(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Inserts the given DynaBean in the database, assuming the primary key values are specified.- Parameters:
model
- The database model to usedynaBean
- The bean to insert- Throws:
DatabaseOperationException
-
insert
void insert(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Inserts the bean. If one of the columns is an auto-incremented column, then the bean will also be updated with the column value generated by the database. Note that the connection will not be closed by this method.- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
insert
Inserts the given beans in the database, assuming the primary key values are specified. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint).- Parameters:
model
- The database model to usedynaBeans
- The beans to insert- Throws:
DatabaseOperationException
-
insert
void insert(Connection connection, Database model, Collection dynaBeans) throws DatabaseOperationException Inserts the given beans. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint). This method does not close the connection.- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBeans
- The beans- Throws:
DatabaseOperationException
-
getUpdateSql
Returns the sql for updating the given bean in the database.- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The update sql
-
update
void update(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Updates the given bean in the database, assuming the primary key values are specified.- Parameters:
model
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
update
void update(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Updates the row which maps to the given bean.- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
getDeleteSql
Returns the sql for deleting the given bean from the database.- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The sql
-
delete
void delete(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Deletes the given bean from the database, assuming the primary key values are specified.- Parameters:
model
- The database model to usedynaBean
- The bean to delete- Throws:
DatabaseOperationException
-
delete
void delete(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Deletes the row which maps to the given bean from the database.- Parameters:
model
- The database model to usedynaBean
- The beanconnection
- The database connection- Throws:
DatabaseOperationException
-
readModelFromDatabase
Reads the database model from the live database as specified by the data source set for this platform.- Parameters:
name
- The name of the resulting database;null
when the default name (the catalog) is desired which might benull
itself though- Returns:
- The database model
- Throws:
DatabaseOperationException
- If an error occurred during reading the model
-
readModelFromDatabase
Database readModelFromDatabase(String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException Reads the database model from the live database as specified by the data source set for this platform.- Parameters:
name
- The name of the resulting database;null
when the default name (the catalog) is desired which might benull
itself thoughcatalog
- The catalog to access in the database; usenull
for the default valueschema
- The schema to access in the database; usenull
for the default valuetableTypes
- The table types to process; usenull
or an empty list for the default ones- Returns:
- The database model
- Throws:
DatabaseOperationException
- If an error occurred during reading the model
-
readModelFromDatabase
Database readModelFromDatabase(Connection connection, String name) throws DatabaseOperationException Reads the database model from the live database to which the given connection is pointing.- Parameters:
connection
- The connection to the databasename
- The name of the resulting database;null
when the default name (the catalog) is desired which might benull
itself though- Returns:
- The database model
- Throws:
DatabaseOperationException
- If an error occurred during reading the model
-
readModelFromDatabase
Database readModelFromDatabase(Connection connection, String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException Reads the database model from the live database to which the given connection is pointing.- Parameters:
connection
- The connection to the databasename
- The name of the resulting database;null
when the default name (the catalog) is desired which might benull
itself thoughcatalog
- The catalog to access in the database; usenull
for the default valueschema
- The schema to access in the database; usenull
for the default valuetableTypes
- The table types to process; usenull
or an empty list for the default ones- Returns:
- The database model
- Throws:
DatabaseOperationException
- If an error occurred during reading the model
-