Class PlatformImplBase
java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.util.JdbcSupport
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.platform.PlatformImplBase
- All Implemented Interfaces:
Platform
- Direct Known Subclasses:
AxionPlatform
,CloudscapePlatform
,Db2Platform
,FirebirdPlatform
,HsqlDbPlatform
,InterbasePlatform
,MckoiPlatform
,MSSqlPlatform
,MySqlPlatform
,Oracle8Platform
,PostgreSqlPlatform
,SapDbPlatform
,SybasePlatform
Base class for platform implementations.
- Version:
- $Revision: 231110 $
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
The default name for models read from the database, if no name as given. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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
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 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.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.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.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
(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.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.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.protected boolean
exists
(Connection connection, 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.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 desiredModel) Returns the SQL for altering the database schema so that it match the given model.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.getAlterTablesSql
(Connection connection, Database desiredModel) Returns the SQL for altering the database schema so that it match the given model.getAlterTablesSql
(Connection connection, Database desiredModel, 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 desiredModel) 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 desiredModel, 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.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.protected org.apache.commons.logging.Log
getLog()
Returns the log for this platform.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.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.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.protected void
logWarnings
(Connection connection) Logs any warnings associated to the given connection.protected void
Allows the platform to postprocess the model just read from the database.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
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
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.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
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.Methods inherited from class edu.internet2.middleware.grouper.ext.org.apache.ddlutils.util.JdbcSupport
borrowConnection, closeStatement, getDataSource, getPassword, getUsername, returnConnection, setDataSource, setPassword, setUsername
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.internet2.middleware.grouper.ext.org.apache.ddlutils.Platform
borrowConnection, getDataSource, getName, getPassword, getUsername, returnConnection, setDataSource, setPassword, setUsername
-
Field Details
-
MODEL_DEFAULT_NAME
The default name for models read from the database, if no name as given.- See Also:
-
-
Constructor Details
-
PlatformImplBase
public PlatformImplBase()
-
-
Method Details
-
getSqlBuilder
Returns the sql builder for the this platform.- Specified by:
getSqlBuilder
in interfacePlatform
- Returns:
- The sql builder
-
setSqlBuilder
Sets the sql builder for this platform.- Parameters:
builder
- The sql builder
-
getModelReader
Returns the model reader (which reads a database model from a live database) for this platform.- Specified by:
getModelReader
in interfacePlatform
- Returns:
- The model reader
-
setModelReader
Sets the model reader for this platform.- Parameters:
modelReader
- The model reader
-
getPlatformInfo
Returns the info object for this platform.- Specified by:
getPlatformInfo
in interfacePlatform
- Returns:
- The info object
-
isScriptModeOn
public 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.- Specified by:
isScriptModeOn
in interfacePlatform
- Returns:
true
if script mode is on
-
setScriptModeOn
public 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.- Specified by:
setScriptModeOn
in interfacePlatform
- Parameters:
scriptModeOn
-true
if script mode is on
-
isSqlCommentsOn
public boolean isSqlCommentsOn()Determines whether SQL comments are generated.- Specified by:
isSqlCommentsOn
in interfacePlatform
- Returns:
true
if SQL comments shall be generated
-
setSqlCommentsOn
public void setSqlCommentsOn(boolean sqlCommentsOn) Specifies whether SQL comments shall be generated.- Specified by:
setSqlCommentsOn
in interfacePlatform
- Parameters:
sqlCommentsOn
-true
if SQL comments shall be generated
-
isDelimitedIdentifierModeOn
public 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- Specified by:
isDelimitedIdentifierModeOn
in interfacePlatform
- Returns:
true
if delimited identifiers are used
-
setDelimitedIdentifierModeOn
public void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn) Specifies whether delimited identifiers are used or normal SQL92 identifiers.- Specified by:
setDelimitedIdentifierModeOn
in interfacePlatform
- Parameters:
delimitedIdentifierModeOn
-true
if delimited identifiers shall be used
-
isIdentityOverrideOn
public 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.- Specified by:
isIdentityOverrideOn
in interfacePlatform
- Returns:
true
if identity override is enabled (the default)
-
setIdentityOverrideOn
public 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.- Specified by:
setIdentityOverrideOn
in interfacePlatform
- Parameters:
identityOverrideOn
-true
if identity override is enabled (the default)
-
isForeignKeysSorted
public boolean isForeignKeysSorted()Determines whether foreign keys of a table read from a live database are alphabetically sorted.- Specified by:
isForeignKeysSorted
in interfacePlatform
- Returns:
true
if read foreign keys are sorted
-
setForeignKeysSorted
public void setForeignKeysSorted(boolean foreignKeysSorted) Specifies whether foreign keys read from a live database, shall be alphabetically sorted.- Specified by:
setForeignKeysSorted
in interfacePlatform
- Parameters:
foreignKeysSorted
-true
if read foreign keys shall be sorted
-
getLog
protected org.apache.commons.logging.Log getLog()Returns the log for this platform.- Returns:
- The log
-
logWarnings
Logs any warnings associated to the given connection. Note that the connection needs to be open for this.- Parameters:
connection
- The open connection- Throws:
SQLException
-
evaluateBatch
Executes a series of sql statements which must be seperated by the delimiter configured asPlatformInfo.getSqlCommandDelimiter()
of the info object of this platform.- Specified by:
evaluateBatch
in interfacePlatform
- 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
public 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- Specified by:
evaluateBatch
in interfacePlatform
- 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.- Specified by:
shutdownDatabase
in interfacePlatform
- 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.- Specified by:
shutdownDatabase
in interfacePlatform
- Parameters:
connection
- The connection to the database- Throws:
DatabaseOperationException
-
createDatabase
public 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 viaPlatform.setDataSource(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.- Specified by:
createDatabase
in interfacePlatform
- 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
public 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 viaPlatform.setDataSource(DataSource)
because it is not possible to retrieve the connection information from it without establishing a connection.- Specified by:
dropDatabase
in interfacePlatform
- 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
public void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Specified by:
createTables
in interfacePlatform
- 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
public void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Specified by:
createTables
in interfacePlatform
- 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.- Specified by:
getCreateTablesSql
in interfacePlatform
- 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
public void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Specified by:
createTables
in interfacePlatform
- 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
public void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException Creates the tables defined in the database model.- Specified by:
createTables
in interfacePlatform
- 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
public String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) Returns the SQL for creating the tables defined in the database model.- Specified by:
getCreateTablesSql
in interfacePlatform
- 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
public void alterTables(Database desiredDb, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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.- Specified by:
getAlterTablesSql
in interfacePlatform
- Parameters:
desiredDb
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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
public String getAlterTablesSql(Database desiredDb, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- Parameters:
desiredDb
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(Connection connection, Database desiredModel, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- Parameters:
connection
- 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 occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
public String getAlterTablesSql(Connection connection, Database desiredModel) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(Connection connection, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- Parameters:
connection
- 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 occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
public String getAlterTablesSql(Connection connection, Database desiredModel, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- Parameters:
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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 valuedesiredModel
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
public String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- 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 valuedesiredModel
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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 valuedesiredModel
- 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
public String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- 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 valuedesiredModel
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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 valuedesiredModel
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred- Throws:
DatabaseOperationException
-
getAlterTablesSql
public String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- 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 valuedesiredModel
- The desired database schema- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
alterTables
public void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException Alters the database schema so that it match the given model.- Specified by:
alterTables
in interfacePlatform
- 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 valuedesiredModel
- 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
public String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException Returns the SQL for altering the database schema so that it match the given model.- Specified by:
getAlterTablesSql
in interfacePlatform
- 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 valuedesiredModel
- The desired database schemaparams
- The parameters used in the creation- Returns:
- The SQL statements
- Throws:
DatabaseOperationException
-
dropTable
public void dropTable(Connection connection, Database model, Table table, boolean continueOnError) throws DatabaseOperationException Drops the specified table and all foreign keys pointing to it.- Specified by:
dropTable
in interfacePlatform
- 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
-
dropTable
public void dropTable(Database model, Table table, boolean continueOnError) throws DatabaseOperationException Drops the specified table and all foreign keys pointing to it.- Specified by:
dropTable
in interfacePlatform
- 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.- Specified by:
getDropTableSql
in interfacePlatform
- Parameters:
model
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The SQL statements
-
dropTables
Drops the tables defined in the given database.- Specified by:
dropTables
in interfacePlatform
- Parameters:
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Throws:
DatabaseOperationException
-
dropTables
public void dropTables(Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException Drops the tables defined in the given database.- Specified by:
dropTables
in interfacePlatform
- Parameters:
connection
- The connection to the databasemodel
- 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.- Specified by:
getDropTablesSql
in interfacePlatform
- Parameters:
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred- Returns:
- The SQL statements
-
query
Performs the given SQL query returning an iterator over the results.- Specified by:
query
in interfacePlatform
- 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
public Iterator query(Database model, String sql, Collection parameters) throws DatabaseOperationException Performs the given parameterized SQL query returning an iterator over the results.- Specified by:
query
in interfacePlatform
- 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
public Iterator query(Database model, String sql, Table[] queryHints) throws DatabaseOperationException Performs the given SQL query returning an iterator over the results.- Specified by:
query
in interfacePlatform
- 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
public Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException Performs the given parameterized SQL query returning an iterator over the results.- Specified by:
query
in interfacePlatform
- 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 thePlatform.query(Database, String)
method all beans will be materialized and the connection will be closed before returning the beans.- Specified by:
fetch
in interfacePlatform
- 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 thePlatform.query(Database, String)
method all beans will be materialized and the connection will be closed before returning the beans.- Specified by:
fetch
in interfacePlatform
- 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
Queries for a list of dyna beans representing rows of the given query. In contrast to thePlatform.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).- Specified by:
fetch
in interfacePlatform
- 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
public 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 thePlatform.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).- Specified by:
fetch
in interfacePlatform
- 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
public List fetch(Database model, String sql, Collection parameters) throws DatabaseOperationException Queries for a list of dyna beans representing rows of the given query. In contrast to thePlatform.query(Database, String, Collection)
method all beans will be materialized and the connection will be closed before returning the beans.- Specified by:
fetch
in interfacePlatform
- Parameters:
model
- The database model to usesql
- The parameterized queryparameters
- The parameter values- Returns:
- The dyna beans resulting from the query
- Throws:
DatabaseOperationException
-
fetch
public 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 thePlatform.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).- Specified by:
fetch
in interfacePlatform
- 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
public 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 thePlatform.query(Database, String, Collection)
method all beans will be materialized and the connection will be closed before returning the beans.- Specified by:
fetch
in interfacePlatform
- 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
public 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 thePlatform.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).- Specified by:
fetch
in interfacePlatform
- 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
-
createInsertSql
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. If a concrete bean is given, then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.- Parameters:
model
- The database modeldynaClass
- The typeproperties
- The properties to writebean
- Optionally the concrete bean to insert- Returns:
- The SQL required to insert an instance of the class
-
createSelectLastInsertIdSql
Creates the SQL for querying for the id generated by the last insert of an object of the given type.- Parameters:
model
- The database modeldynaClass
- The type- Returns:
- The SQL required for querying for the id, or
null
if the database does not support this
-
getInsertSql
Returns the sql for inserting the given bean.- Specified by:
getInsertSql
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The insert sql
-
insert
public 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.- Specified by:
insert
in interfacePlatform
- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
insert
public 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.- Specified by:
insert
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean to insert- Throws:
DatabaseOperationException
-
insert
public 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.- Specified by:
insert
in interfacePlatform
- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBeans
- The beans- 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).- Specified by:
insert
in interfacePlatform
- Parameters:
model
- The database model to usedynaBeans
- The beans to insert- Throws:
DatabaseOperationException
-
beforeInsert
Allows platforms to issue statements directly before rows are inserted into the specified table.- Parameters:
connection
- The connection used for the insertiontable
- The table that the rows are inserted into- Throws:
SQLException
-
afterInsert
Allows platforms to issue statements directly after rows have been inserted into the specified table.- Parameters:
connection
- The connection used for the insertiontable
- The table that the rows have been inserted into- Throws:
SQLException
-
createUpdateSql
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. If a concrete bean is given, then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.- Parameters:
model
- The database modeldynaClass
- The typeprimaryKeys
- The primary keysproperties
- The properties to writebean
- Optionally the concrete bean to update- Returns:
- The SQL required to update the instance
-
getUpdateSql
Returns the sql for updating the given bean in the database.- Specified by:
getUpdateSql
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The update sql
-
update
public void update(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException Updates the row which maps to the given bean.- Specified by:
update
in interfacePlatform
- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
update
public 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.- Specified by:
update
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
beforeUpdate
Allows platforms to issue statements directly before rows are updated in the specified table.- Parameters:
connection
- The connection used for the updatetable
- The table that the rows are updateed into- Throws:
SQLException
-
afterUpdate
Allows platforms to issue statements directly after rows have been updated in the specified table.- Parameters:
connection
- The connection used for the updatetable
- The table that the rows have been updateed into- Throws:
SQLException
-
exists
Determines whether the given dyna bean is stored in the database.- Parameters:
dynaBean
- The beanconnection
- The connection- Returns:
true
if this dyna bean has a primary key
-
store
public 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.- Specified by:
store
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean to store- Throws:
DatabaseOperationException
-
createDeleteSql
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. If a concrete bean is given, then a concrete delete statement is created, otherwise a delete statement usable in a prepared statement is build.- Parameters:
model
- The database modeldynaClass
- The typeprimaryKeys
- The primary keysbean
- Optionally the concrete bean to update- Returns:
- The SQL required to delete the instance
-
getDeleteSql
Returns the sql for deleting the given bean from the database.- Specified by:
getDeleteSql
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean- Returns:
- The sql
-
delete
public 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.- Specified by:
delete
in interfacePlatform
- Parameters:
model
- The database model to usedynaBean
- The bean to delete- Throws:
DatabaseOperationException
-
delete
public 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.- Specified by:
delete
in interfacePlatform
- Parameters:
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean- Throws:
DatabaseOperationException
-
readModelFromDatabase
Reads the database model from the live database as specified by the data source set for this platform.- Specified by:
readModelFromDatabase
in interfacePlatform
- 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
public Database readModelFromDatabase(Connection connection, String name) throws DatabaseOperationException Reads the database model from the live database to which the given connection is pointing.- Specified by:
readModelFromDatabase
in interfacePlatform
- 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
public 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.- Specified by:
readModelFromDatabase
in interfacePlatform
- 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
public 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.- Specified by:
readModelFromDatabase
in interfacePlatform
- 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
-
postprocessModelFromDatabase
Allows the platform to postprocess the model just read from the database.- Parameters:
model
- The model
-
toColumnValues
protected HashMap toColumnValues(SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean) Derives the column values for the given dyna properties from the dyna bean.- Parameters:
properties
- The propertiesbean
- The bean- Returns:
- The values indexed by the column names
-
setObject
protected void setObject(PreparedStatement statement, int sqlIndex, org.apache.commons.beanutils.DynaBean dynaBean, SqlDynaProperty property) throws SQLException Sets a parameter of the prepared statement based on the type of the column of the property.- Parameters:
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 column- Throws:
SQLException
-
setStatementParameterValue
protected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int typeCode, Object value) throws SQLException This is the core method to set the parameter of a prepared statement to a given value. The primary purpose of this method is to call the appropriate method on the statement, and to give database-specific implementations the ability to change this behavior.- Parameters:
statement
- The statementsqlIndex
- The parameter indextypeCode
- The JDBC type codevalue
- The value- Throws:
SQLException
- If an error occurred while setting the parameter value
-
getObjectFromResultSet
protected Object getObjectFromResultSet(ResultSet resultSet, String columnName, Table table) throws SQLException Helper method esp. for theModelBasedResultSetIterator
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.
The method is defined here rather than in theModelBasedResultSetIterator
class so that concrete platforms can modify its behavior.- Parameters:
resultSet
- The result setcolumnName
- The name of the columntable
- The table- Returns:
- The value
- Throws:
SQLException
-
getObjectFromResultSet
protected Object getObjectFromResultSet(ResultSet resultSet, Column column, int idx) throws SQLException Helper method for retrieving the value for a column from the given result set using the type code of the column.- Parameters:
resultSet
- The result setcolumn
- The columnidx
- The value's index in the result set (starting from 1)- Returns:
- The value
- Throws:
SQLException
-
extractColumnValue
protected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType) throws SQLException This is the core method to retrieve a value for a column from a result set. Its primary purpose is to call the appropriate method on the result set, and to provide an extension point where database-specific implementations can change this behavior.- Parameters:
resultSet
- The result set to extract the value fromcolumnName
- The name of the column; can benull
in which case thecolumnIdx
will be used insteadcolumnIdx
- The index of the column's value in the result set; is only used ifcolumnName
isnull
jdbcType
- The jdbc type to extract- Returns:
- The value
- Throws:
SQLException
- If an error occurred while accessing the result set
-
createResultSetIterator
protected ModelBasedResultSetIterator createResultSetIterator(Database model, ResultSet resultSet, Table[] queryHints) Creates an iterator over the given result set.- Parameters:
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)- Returns:
- The iterator
-