public abstract class PlatformImplBase extends JdbcSupport implements Platform
| Modifier and Type | Field and Description |
|---|---|
protected static String |
MODEL_DEFAULT_NAME
The default name for models read from the database, if no name as given.
|
| Constructor and Description |
|---|
PlatformImplBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterInsert(Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been inserted into
the specified table.
|
protected void |
afterUpdate(Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been updated in
the specified table.
|
void |
alterTables(Connection connection,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model.
|
void |
alterTables(Database 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.
|
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(Connection connection,
Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Connection connection,
Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
void |
createTables(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model.
|
protected String |
createUpdateSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] primaryKeys,
SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean bean)
Creates the SQL for updating an object of the given type.
|
void |
delete(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Deletes the row which maps to the given bean from the database.
|
void |
delete(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Deletes the given bean from the database, assuming the primary key values are specified.
|
void |
dropDatabase(String jdbcDriverClassName,
String connectionUrl,
String username,
String password)
Drops the database specified by the given parameters.
|
void |
dropTable(Connection connection,
Database model,
Table table,
boolean continueOnError)
Drops the specified table and all foreign keys pointing to it.
|
void |
dropTable(Database model,
Table table,
boolean continueOnError)
Drops the specified table and all foreign keys pointing to it.
|
void |
dropTables(Connection connection,
Database model,
boolean continueOnError)
Drops the tables defined in the given database.
|
void |
dropTables(Database model,
boolean continueOnError)
Drops the tables defined in the given database.
|
int |
evaluateBatch(Connection connection,
String sql,
boolean continueOnError)
Executes a series of sql statements which must be seperated by the delimiter
configured as
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform. |
int |
evaluateBatch(String sql,
boolean continueOnError)
Executes a series of sql statements which must be seperated by the delimiter
configured as
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform. |
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.
|
List |
fetch(Database model,
String sql)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Collection parameters,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query.
|
List |
fetch(Database model,
String sql,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query.
|
String |
getAlterTablesSql(Connection connection,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Connection connection,
String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Database desiredDb)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(Database desiredDb,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(String catalog,
String schema,
String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getAlterTablesSql(String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model.
|
String |
getCreateTablesSql(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getCreateTablesSql(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model.
|
String |
getDeleteSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for deleting the given bean from the database.
|
String |
getDropTableSql(Database model,
Table table,
boolean continueOnError)
Returns the SQL for dropping the given table and all foreign keys pointing to it.
|
String |
getDropTablesSql(Database model,
boolean continueOnError)
Returns the SQL for dropping the tables defined in the given database.
|
String |
getInsertSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for inserting the given bean.
|
protected org.apache.commons.logging.Log |
getLog()
Returns the log for this platform.
|
JdbcModelReader |
getModelReader()
Returns the model reader (which reads a database model from a live database) for this platform.
|
protected Object |
getObjectFromResultSet(ResultSet resultSet,
Column column,
int idx)
Helper method for retrieving the value for a column from the given result set
using the type code of the column.
|
protected Object |
getObjectFromResultSet(ResultSet resultSet,
String columnName,
Table table)
Helper method esp.
|
PlatformInfo |
getPlatformInfo()
Returns the info object for this platform.
|
SqlBuilder |
getSqlBuilder()
Returns the sql builder for the this platform.
|
String |
getUpdateSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for updating the given bean in the database.
|
void |
insert(Connection connection,
Database model,
Collection dynaBeans)
Inserts the given beans.
|
void |
insert(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Inserts the bean.
|
void |
insert(Database model,
Collection dynaBeans)
Inserts the given beans in the database, assuming the primary key values are specified.
|
void |
insert(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Inserts the given DynaBean in the database, assuming the primary key values are specified.
|
boolean |
isDelimitedIdentifierModeOn()
Determines whether delimited identifiers are used or normal SQL92 identifiers
(which may only contain alphanumerical characters and the underscore, must start
with a letter and cannot be a reserved keyword).
|
boolean |
isForeignKeysSorted()
Determines whether foreign keys of a table read from a live database
are alphabetically sorted.
|
boolean |
isIdentityOverrideOn()
Determines whether SQL insert statements can specify values for identity columns.
|
boolean |
isScriptModeOn()
Determines whether script mode is on.
|
boolean |
isSqlCommentsOn()
Determines whether SQL comments are generated.
|
protected void |
logWarnings(Connection connection)
Logs any warnings associated to the given connection.
|
protected void |
postprocessModelFromDatabase(Database model)
Allows the platform to postprocess the model just read from the database.
|
Iterator |
query(Database model,
String sql)
Performs the given SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Collection parameters)
Performs the given parameterized SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Collection parameters,
Table[] queryHints)
Performs the given parameterized SQL query returning an iterator over the results.
|
Iterator |
query(Database model,
String sql,
Table[] queryHints)
Performs the given SQL query returning an iterator over the results.
|
Database |
readModelFromDatabase(Connection connection,
String name)
Reads the database model from the live database to which the given connection is pointing.
|
Database |
readModelFromDatabase(Connection connection,
String name,
String catalog,
String schema,
String[] tableTypes)
Reads the database model from the live database to which the given connection is pointing.
|
Database |
readModelFromDatabase(String name)
Reads the database model from the live database as specified by the data source set for
this platform.
|
Database |
readModelFromDatabase(String name,
String catalog,
String schema,
String[] tableTypes)
Reads the database model from the live database as specified by the data source set for
this platform.
|
void |
setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
Specifies whether delimited identifiers are used or normal SQL92 identifiers.
|
void |
setForeignKeysSorted(boolean foreignKeysSorted)
Specifies whether foreign keys read from a live database, shall be
alphabetically sorted.
|
void |
setIdentityOverrideOn(boolean identityOverrideOn)
Specifies whether SQL insert statements can specify values for identity columns.
|
protected void |
setModelReader(JdbcModelReader modelReader)
Sets the model reader for this platform.
|
protected void |
setObject(PreparedStatement statement,
int sqlIndex,
org.apache.commons.beanutils.DynaBean dynaBean,
SqlDynaProperty property)
Sets a parameter of the prepared statement based on the type of the column of the property.
|
void |
setScriptModeOn(boolean scriptModeOn)
Specifies whether script mode is on.
|
protected void |
setSqlBuilder(SqlBuilder builder)
Sets the sql builder for this platform.
|
void |
setSqlCommentsOn(boolean sqlCommentsOn)
Specifies whether SQL comments shall be generated.
|
protected void |
setStatementParameterValue(PreparedStatement statement,
int sqlIndex,
int typeCode,
Object value)
This is the core method to set the parameter of a prepared statement to a given value.
|
void |
shutdownDatabase()
Performs a shutdown at the database.
|
void |
shutdownDatabase(Connection connection)
Performs a shutdown at the database.
|
void |
store(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Stores the given bean in the database, inserting it if there is no primary key
otherwise the bean is updated in the database.
|
protected HashMap |
toColumnValues(SqlDynaProperty[] properties,
org.apache.commons.beanutils.DynaBean bean)
Derives the column values for the given dyna properties from the dyna bean.
|
void |
update(Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Updates the row which maps to the given bean.
|
void |
update(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Updates the given bean in the database, assuming the primary key values are specified.
|
borrowConnection, closeStatement, getDataSource, getPassword, getUsername, returnConnection, setDataSource, setPassword, setUsernameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitborrowConnection, getDataSource, getName, getPassword, getUsername, returnConnection, setDataSource, setPassword, setUsernameprotected static final String MODEL_DEFAULT_NAME
public SqlBuilder getSqlBuilder()
getSqlBuilder in interface Platformprotected void setSqlBuilder(SqlBuilder builder)
builder - The sql builderpublic JdbcModelReader getModelReader()
getModelReader in interface Platformprotected void setModelReader(JdbcModelReader modelReader)
modelReader - The model readerpublic PlatformInfo getPlatformInfo()
getPlatformInfo in interface Platformpublic boolean isScriptModeOn()
isScriptModeOn in interface Platformtrue if script mode is onpublic void setScriptModeOn(boolean scriptModeOn)
setScriptModeOn in interface PlatformscriptModeOn - true if script mode is onpublic boolean isSqlCommentsOn()
isSqlCommentsOn in interface Platformtrue if SQL comments shall be generatedpublic void setSqlCommentsOn(boolean sqlCommentsOn)
setSqlCommentsOn in interface PlatformsqlCommentsOn - true if SQL comments shall be generatedpublic boolean isDelimitedIdentifierModeOn()
isDelimitedIdentifierModeOn in interface Platformtrue if delimited identifiers are usedpublic void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
setDelimitedIdentifierModeOn in interface PlatformdelimitedIdentifierModeOn - true if delimited identifiers shall be usedpublic boolean isIdentityOverrideOn()
PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the
insert methods will ignore values for identity columns.isIdentityOverrideOn in interface Platformtrue if identity override is enabled (the default)public void setIdentityOverrideOn(boolean identityOverrideOn)
PlatformInfo.isIdentityOverrideAllowed()). If this is off, then the
insert methods will ignore values for identity columns.setIdentityOverrideOn in interface PlatformidentityOverrideOn - true if identity override is enabled (the default)public boolean isForeignKeysSorted()
isForeignKeysSorted in interface Platformtrue if read foreign keys are sortedpublic void setForeignKeysSorted(boolean foreignKeysSorted)
setForeignKeysSorted in interface PlatformforeignKeysSorted - true if read foreign keys shall be sortedprotected org.apache.commons.logging.Log getLog()
protected void logWarnings(Connection connection) throws SQLException
connection - The open connectionSQLExceptionpublic int evaluateBatch(String sql, boolean continueOnError) throws DatabaseOperationException
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform.evaluateBatch in interface Platformsql - The sql statements to executecontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DatabaseOperationException
PlatformInfo.getSqlCommandDelimiter() of the info object
of this platform.
TODO: consider outputting a collection of String or some kind of statement
object from the SqlBuilder instead of having to parse strings hereevaluateBatch in interface Platformconnection - The connection to the databasesql - The sql statements to executecontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void shutdownDatabase()
throws DatabaseOperationException
shutdownDatabase in interface PlatformDatabaseOperationExceptionpublic void shutdownDatabase(Connection connection) throws DatabaseOperationException
shutdownDatabase in interface Platformconnection - The connection to the databaseDatabaseOperationExceptionpublic void createDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters) throws DatabaseOperationException, UnsupportedOperationException
Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection.createDatabase in interface PlatformjdbcDriverClassName - The jdbc driver class nameconnectionUrl - The url to connect to the database if it were already createdusername - The username for creating the databasepassword - The password for creating the databaseparameters - Additional parameters relevant to database creation (which are platform specific)DatabaseOperationExceptionUnsupportedOperationExceptionpublic void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password) throws DatabaseOperationException, UnsupportedOperationException
Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection.dropDatabase in interface PlatformjdbcDriverClassName - The jdbc driver class nameconnectionUrl - The url to connect to the databaseusername - The username for creating the databasepassword - The password for creating the databaseDatabaseOperationExceptionUnsupportedOperationExceptionpublic void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformconnection - The connection to the databasemodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql in interface Platformmodel - The database modeldropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredpublic void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables in interface Platformconnection - The connection to the databasemodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql in interface Platformmodel - The database modelparams - The parameters used in the creationdropTablesFirst - Whether to drop the tables prior to creating them (anew)continueOnError - Whether to continue executing the sql commands when an error occurredpublic void alterTables(Database desiredDb, boolean continueOnError) throws DatabaseOperationException
alterTables in interface PlatformdesiredDb - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Database desiredDb) throws DatabaseOperationException
getAlterTablesSql in interface PlatformdesiredDb - The desired database schemaDatabaseOperationExceptionpublic void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface PlatformdesiredDb - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Database desiredDb, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface PlatformdesiredDb - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic void alterTables(Connection connection, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaDatabaseOperationExceptionpublic void alterTables(Connection connection, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifieddesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaDatabaseOperationExceptionpublic void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemacontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaDatabaseOperationExceptionpublic void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationcontinueOnError - Whether to continue with the next sql statement when an error occurredDatabaseOperationExceptionpublic String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql in interface Platformconnection - A connection to the existing database that shall be modifiedcatalog - The catalog in the existing database to read (can be a pattern);
use null for the platform-specific default valueschema - The schema in the existing database to read (can be a pattern);
use null for the platform-specific default valuetableTypes - The table types to read from the existing database;
use null or an empty array for the platform-specific default valuedesiredModel - The desired database schemaparams - The parameters used in the creationDatabaseOperationExceptionpublic void dropTable(Connection connection, Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable in interface Platformconnection - The connection to the databasemodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void dropTable(Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable in interface Platformmodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getDropTableSql(Database model, Table table, boolean continueOnError)
getDropTableSql in interface Platformmodel - The database modeltable - The table to dropcontinueOnError - Whether to continue executing the sql commands when an error occurredpublic void dropTables(Database model, boolean continueOnError) throws DatabaseOperationException
dropTables in interface Platformmodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic void dropTables(Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException
dropTables in interface Platformconnection - The connection to the databasemodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredDatabaseOperationExceptionpublic String getDropTablesSql(Database model, boolean continueOnError)
getDropTablesSql in interface Platformmodel - The database modelcontinueOnError - Whether to continue executing the sql commands when an error occurredpublic Iterator query(Database model, String sql) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performDatabaseOperationExceptionpublic Iterator query(Database model, String sql, Collection parameters) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performparameters - The query parameter valuesDatabaseOperationExceptionpublic Iterator query(Database model, String sql, Table[] queryHints) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException
query in interface Platformmodel - The database model to usesql - The sql query to performparameters - The query parameter valuesqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.fetch in interface Platformmodel - The database model to usesql - The sql queryDatabaseOperationExceptionpublic List fetch(Database model, String sql, Table[] queryHints) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.fetch in interface Platformmodel - The database model to usesql - The sql queryqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql, int start, int end) throws DatabaseOperationException
Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans.
Also, the two int parameters specify which rows of the result set to use.
If there are more rows than desired, they will be ignored (and not read
from the database).fetch in interface Platformmodel - The database model to usesql - The sql querystart - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Table[] queryHints, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Table[]) method all
beans will be materialized and the connection will be closed before
returning the beans. Also, the two int parameters specify which rows of
the result set to use. If there are more rows than desired, they will be
ignored (and not read from the database).fetch in interface Platformmodel - The database model to usesql - The sql queryqueryHints - The tables that are queried (optional)start - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters) throws DatabaseOperationException
Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans.fetch in interface Platformmodel - The database model to usesql - The parameterized queryparameters - The parameter valuesDatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Collection) method all
beans will be materialized and the connection will be closed before returning
the beans. Also, the two int parameters specify which rows of the result set
to use. If there are more rows than desired, they will be ignored (and not
read from the database).fetch in interface Platformmodel - The database model to usesql - The parameterized sql queryparameters - The parameter valuesstart - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, Table[] queryHints) throws DatabaseOperationException
Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans.fetch in interface Platformmodel - The database model to usesql - The parameterized queryparameters - The parameter valuesqueryHints - The tables that are queried (optional)DatabaseOperationExceptionpublic List fetch(Database model, String sql, Collection parameters, Table[] queryHints, int start, int end) throws DatabaseOperationException
Platform.query(Database, String, Collection, Table[])
method all beans will be materialized and the connection will be closed
before returning the beans. Also, the two int parameters specify which
rows of the result set to use. If there are more rows than desired, they
will be ignored (and not read from the database).fetch in interface Platformmodel - The database model to usesql - The parameterized sql queryparameters - The parameter valuesqueryHints - The tables that are queried (optional)start - Row number to start from (0 for first row)end - Row number to stop at (inclusively; -1 for last row)DatabaseOperationExceptionprotected String createInsertSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeproperties - The properties to writebean - Optionally the concrete bean to insertprotected String createSelectLastInsertIdSql(Database model, SqlDynaClass dynaClass)
model - The database modeldynaClass - The typenull if the database does not
support thispublic String getInsertSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getInsertSql in interface Platformmodel - The database model to usedynaBean - The beanpublic void insert(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic void insert(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert in interface Platformmodel - The database model to usedynaBean - The bean to insertDatabaseOperationExceptionpublic void insert(Connection connection, Database model, Collection dynaBeans) throws DatabaseOperationException
insert in interface Platformconnection - The database connectionmodel - The database model to usedynaBeans - The beansDatabaseOperationExceptionpublic void insert(Database model, Collection dynaBeans) throws DatabaseOperationException
insert in interface Platformmodel - The database model to usedynaBeans - The beans to insertDatabaseOperationExceptionprotected void beforeInsert(Connection connection, Table table) throws SQLException
connection - The connection used for the insertiontable - The table that the rows are inserted intoSQLExceptionprotected void afterInsert(Connection connection, Table table) throws SQLException
connection - The connection used for the insertiontable - The table that the rows have been inserted intoSQLExceptionprotected String createUpdateSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeprimaryKeys - The primary keysproperties - The properties to writebean - Optionally the concrete bean to updatepublic String getUpdateSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getUpdateSql in interface Platformmodel - The database model to usedynaBean - The beanpublic void update(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic void update(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update in interface Platformmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionprotected void beforeUpdate(Connection connection, Table table) throws SQLException
connection - The connection used for the updatetable - The table that the rows are updateed intoSQLExceptionprotected void afterUpdate(Connection connection, Table table) throws SQLException
connection - The connection used for the updatetable - The table that the rows have been updateed intoSQLExceptionprotected boolean exists(Connection connection, org.apache.commons.beanutils.DynaBean dynaBean)
dynaBean - The beanconnection - The connectiontrue if this dyna bean has a primary keypublic void store(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
store in interface Platformmodel - The database model to usedynaBean - The bean to storeDatabaseOperationExceptionprotected String createDeleteSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, org.apache.commons.beanutils.DynaBean bean)
model - The database modeldynaClass - The typeprimaryKeys - The primary keysbean - Optionally the concrete bean to updatepublic String getDeleteSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getDeleteSql in interface Platformmodel - The database model to usedynaBean - The beanpublic void delete(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete in interface Platformmodel - The database model to usedynaBean - The bean to deleteDatabaseOperationExceptionpublic void delete(Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete in interface Platformconnection - The database connectionmodel - The database model to usedynaBean - The beanDatabaseOperationExceptionpublic Database readModelFromDatabase(String name) throws DatabaseOperationException
readModelFromDatabase in interface Platformname - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name) throws DatabaseOperationException
readModelFromDatabase in interface Platformconnection - The connection to the databasename - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase in interface Platformname - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughcatalog - The catalog to access in the database; use null for the default valueschema - The schema to access in the database; use null for the default valuetableTypes - The table types to process; use null or an empty list for the default onesDatabaseOperationException - If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name, String catalog, String schema, String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase in interface Platformconnection - The connection to the databasename - The name of the resulting database; null when the default name (the catalog)
is desired which might be null itself thoughcatalog - The catalog to access in the database; use null for the default valueschema - The schema to access in the database; use null for the default valuetableTypes - The table types to process; use null or an empty list for the default onesDatabaseOperationException - If an error occurred during reading the modelprotected void postprocessModelFromDatabase(Database model)
model - The modelprotected HashMap toColumnValues(SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
properties - The propertiesbean - The beanprotected void setObject(PreparedStatement statement, int sqlIndex, org.apache.commons.beanutils.DynaBean dynaBean, SqlDynaProperty property) throws SQLException
statement - The statementsqlIndex - The index of the parameter to set in the statementdynaBean - The bean of which to take the valueproperty - The property of the bean, which also defines the corresponding columnSQLExceptionprotected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int typeCode, Object value) throws SQLException
statement - The statementsqlIndex - The parameter indextypeCode - The JDBC type codevalue - The valueSQLException - If an error occurred while setting the parameter valueprotected Object getObjectFromResultSet(ResultSet resultSet, String columnName, Table table) throws SQLException
ModelBasedResultSetIterator class that retrieves
the value for a column from the given result set. If a table was specified,
and it contains the column, then the jdbc type defined for the column is used for extracting
the value, otherwise the object directly retrieved from the result set is returned.ModelBasedResultSetIterator class
so that concrete platforms can modify its behavior.resultSet - The result setcolumnName - The name of the columntable - The tableSQLExceptionprotected Object getObjectFromResultSet(ResultSet resultSet, Column column, int idx) throws SQLException
resultSet - The result setcolumn - The columnidx - The value's index in the result set (starting from 1)SQLExceptionprotected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType) throws SQLException
resultSet - The result set to extract the value fromcolumnName - The name of the column; can be null in which case the
columnIdx will be used insteadcolumnIdx - The index of the column's value in the result set; is only used if
columnName is nulljdbcType - The jdbc type to extractSQLException - If an error occurred while accessing the result setprotected ModelBasedResultSetIterator createResultSetIterator(Database model, ResultSet resultSet, Table[] queryHints)
model - The database modelresultSet - The result set to iterate overqueryHints - The tables that were queried in the query that produced the
given result set (optional)Copyright © 2005-2013 Apache Software Foundation. All Rights Reserved.