|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ddlutils.util.JdbcSupport
org.apache.ddlutils.platform.PlatformImplBase
public abstract class PlatformImplBase
Base class for platform implementations.
Field Summary | |
---|---|
protected static java.lang.String |
MODEL_DEFAULT_NAME
The default name for models read from the database, if no name as given. |
Constructor Summary | |
---|---|
PlatformImplBase()
|
Method Summary | |
---|---|
protected void |
afterInsert(java.sql.Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been inserted into the specified table. |
protected void |
afterUpdate(java.sql.Connection connection,
Table table)
Allows platforms to issue statements directly after rows have been updated in the specified table. |
void |
alterTables(java.sql.Connection connection,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(java.sql.Connection connection,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(java.sql.Connection connection,
java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(java.sql.Connection connection,
java.lang.String catalog,
java.lang.String schema,
java.lang.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(java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel,
CreationParameters params,
boolean continueOnError)
Alters the database schema so that it match the given model. |
protected void |
beforeInsert(java.sql.Connection connection,
Table table)
Allows platforms to issue statements directly before rows are inserted into the specified table. |
protected void |
beforeUpdate(java.sql.Connection connection,
Table table)
Allows platforms to issue statements directly before rows are updated in the specified table. |
void |
createDatabase(java.lang.String jdbcDriverClassName,
java.lang.String connectionUrl,
java.lang.String username,
java.lang.String password,
java.util.Map parameters)
Creates the database specified by the given parameters. |
protected java.lang.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 java.lang.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,
java.sql.ResultSet resultSet,
Table[] queryHints)
Creates an iterator over the given result set. |
protected java.lang.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(java.sql.Connection connection,
Database model,
boolean dropTablesFirst,
boolean continueOnError)
Creates the tables defined in the database model. |
void |
createTables(java.sql.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 java.lang.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(java.sql.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(java.lang.String jdbcDriverClassName,
java.lang.String connectionUrl,
java.lang.String username,
java.lang.String password)
Drops the database specified by the given parameters. |
void |
dropTable(java.sql.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(java.sql.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(java.sql.Connection connection,
java.lang.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(java.lang.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(java.sql.Connection connection,
org.apache.commons.beanutils.DynaBean dynaBean)
Determines whether the given dyna bean is stored in the database. |
protected java.lang.Object |
extractColumnValue(java.sql.ResultSet resultSet,
java.lang.String columnName,
int columnIdx,
int jdbcType)
This is the core method to retrieve a value for a column from a result set. |
java.util.List |
fetch(Database model,
java.lang.String sql)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
java.util.Collection parameters)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
java.util.Collection parameters,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
java.util.Collection parameters,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
java.util.Collection parameters,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query. |
java.util.List |
fetch(Database model,
java.lang.String sql,
Table[] queryHints,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query. |
java.lang.String |
getAlterTablesSql(java.sql.Connection connection,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(java.sql.Connection connection,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(java.sql.Connection connection,
java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(java.sql.Connection connection,
java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(Database desiredDb)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(Database desiredDb,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getAlterTablesSql(java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes,
Database desiredModel,
CreationParameters params)
Returns the SQL for altering the database schema so that it match the given model. |
java.lang.String |
getCreateTablesSql(Database model,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model. |
java.lang.String |
getCreateTablesSql(Database model,
CreationParameters params,
boolean dropTablesFirst,
boolean continueOnError)
Returns the SQL for creating the tables defined in the database model. |
java.lang.String |
getDeleteSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for deleting the given bean from the database. |
java.lang.String |
getDropTableSql(Database model,
Table table,
boolean continueOnError)
Returns the SQL for dropping the given table and all foreign keys pointing to it. |
java.lang.String |
getDropTablesSql(Database model,
boolean continueOnError)
Returns the SQL for dropping the tables defined in the given database. |
java.lang.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 java.lang.Object |
getObjectFromResultSet(java.sql.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 java.lang.Object |
getObjectFromResultSet(java.sql.ResultSet resultSet,
java.lang.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. |
java.lang.String |
getUpdateSql(Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Returns the sql for updating the given bean in the database. |
void |
insert(java.sql.Connection connection,
Database model,
java.util.Collection dynaBeans)
Inserts the given beans. |
void |
insert(java.sql.Connection connection,
Database model,
org.apache.commons.beanutils.DynaBean dynaBean)
Inserts the bean. |
void |
insert(Database model,
java.util.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(java.sql.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. |
java.util.Iterator |
query(Database model,
java.lang.String sql)
Performs the given SQL query returning an iterator over the results. |
java.util.Iterator |
query(Database model,
java.lang.String sql,
java.util.Collection parameters)
Performs the given parameterized SQL query returning an iterator over the results. |
java.util.Iterator |
query(Database model,
java.lang.String sql,
java.util.Collection parameters,
Table[] queryHints)
Performs the given parameterized SQL query returning an iterator over the results. |
java.util.Iterator |
query(Database model,
java.lang.String sql,
Table[] queryHints)
Performs the given SQL query returning an iterator over the results. |
Database |
readModelFromDatabase(java.sql.Connection connection,
java.lang.String name)
Reads the database model from the live database to which the given connection is pointing. |
Database |
readModelFromDatabase(java.sql.Connection connection,
java.lang.String name,
java.lang.String catalog,
java.lang.String schema,
java.lang.String[] tableTypes)
Reads the database model from the live database to which the given connection is pointing. |
Database |
readModelFromDatabase(java.lang.String name)
Reads the database model from the live database as specified by the data source set for this platform. |
Database |
readModelFromDatabase(java.lang.String name,
java.lang.String catalog,
java.lang.String schema,
java.lang.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(java.sql.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(java.sql.PreparedStatement statement,
int sqlIndex,
int typeCode,
java.lang.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(java.sql.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 java.util.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(java.sql.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. |
Methods inherited from class 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 org.apache.ddlutils.Platform |
---|
borrowConnection, getDataSource, getName, getPassword, getUsername, returnConnection, setDataSource, setPassword, setUsername |
Field Detail |
---|
protected static final java.lang.String MODEL_DEFAULT_NAME
Constructor Detail |
---|
public PlatformImplBase()
Method Detail |
---|
public SqlBuilder getSqlBuilder()
getSqlBuilder
in interface Platform
protected void setSqlBuilder(SqlBuilder builder)
builder
- The sql builderpublic JdbcModelReader getModelReader()
getModelReader
in interface Platform
protected void setModelReader(JdbcModelReader modelReader)
modelReader
- The model readerpublic PlatformInfo getPlatformInfo()
getPlatformInfo
in interface Platform
public boolean isScriptModeOn()
isScriptModeOn
in interface Platform
true
if script mode is onpublic void setScriptModeOn(boolean scriptModeOn)
setScriptModeOn
in interface Platform
scriptModeOn
- true
if script mode is onpublic boolean isSqlCommentsOn()
isSqlCommentsOn
in interface Platform
true
if SQL comments shall be generatedpublic void setSqlCommentsOn(boolean sqlCommentsOn)
setSqlCommentsOn
in interface Platform
sqlCommentsOn
- true
if SQL comments shall be generatedpublic boolean isDelimitedIdentifierModeOn()
isDelimitedIdentifierModeOn
in interface Platform
true
if delimited identifiers are usedpublic void setDelimitedIdentifierModeOn(boolean delimitedIdentifierModeOn)
setDelimitedIdentifierModeOn
in interface Platform
delimitedIdentifierModeOn
- 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 Platform
true
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 Platform
identityOverrideOn
- true
if identity override is enabled (the default)public boolean isForeignKeysSorted()
isForeignKeysSorted
in interface Platform
true
if read foreign keys are sortedpublic void setForeignKeysSorted(boolean foreignKeysSorted)
setForeignKeysSorted
in interface Platform
foreignKeysSorted
- true
if read foreign keys shall be sortedprotected org.apache.commons.logging.Log getLog()
protected void logWarnings(java.sql.Connection connection) throws java.sql.SQLException
connection
- The open connection
java.sql.SQLException
public int evaluateBatch(java.lang.String sql, boolean continueOnError) throws DatabaseOperationException
PlatformInfo.getSqlCommandDelimiter()
of the info object
of this platform.
evaluateBatch
in interface Platform
sql
- The sql statements to executecontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public int evaluateBatch(java.sql.Connection connection, java.lang.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 here
evaluateBatch
in interface Platform
connection
- The connection to the databasesql
- The sql statements to executecontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public void shutdownDatabase() throws DatabaseOperationException
shutdownDatabase
in interface Platform
DatabaseOperationException
public void shutdownDatabase(java.sql.Connection connection) throws DatabaseOperationException
shutdownDatabase
in interface Platform
connection
- The connection to the database
DatabaseOperationException
public void createDatabase(java.lang.String jdbcDriverClassName, java.lang.String connectionUrl, java.lang.String username, java.lang.String password, java.util.Map parameters) throws DatabaseOperationException, java.lang.UnsupportedOperationException
Platform.setDataSource(DataSource)
because it is not possible to
retrieve the connection information from it without establishing a connection.
createDatabase
in interface Platform
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)
DatabaseOperationException
java.lang.UnsupportedOperationException
public void dropDatabase(java.lang.String jdbcDriverClassName, java.lang.String connectionUrl, java.lang.String username, java.lang.String password) throws DatabaseOperationException, java.lang.UnsupportedOperationException
Platform.setDataSource(DataSource)
because it is not possible to
retrieve the connection information from it without establishing a connection.
dropDatabase
in interface Platform
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
DatabaseOperationException
java.lang.UnsupportedOperationException
public void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables
in interface Platform
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
DatabaseOperationException
public void createTables(java.sql.Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables
in interface Platform
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
DatabaseOperationException
public java.lang.String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql
in interface Platform
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
public void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables
in interface Platform
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
DatabaseOperationException
public void createTables(java.sql.Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DatabaseOperationException
createTables
in interface Platform
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
DatabaseOperationException
public java.lang.String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
getCreateTablesSql
in interface Platform
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
public void alterTables(Database desiredDb, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
desiredDb
- The desired database schemacontinueOnError
- Whether to continue with the next sql statement when an error occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(Database desiredDb) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
desiredDb
- The desired database schema
DatabaseOperationException
public void alterTables(Database desiredDb, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
desiredDb
- The desired database schemaparams
- The parameters used in the creationcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(Database desiredDb, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
desiredDb
- The desired database schemaparams
- The parameters used in the creation
DatabaseOperationException
public void alterTables(java.sql.Connection connection, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
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
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.sql.Connection connection, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schema
DatabaseOperationException
public void alterTables(java.sql.Connection connection, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
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
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.sql.Connection connection, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemaparams
- The parameters used in the creation
DatabaseOperationException
public void alterTables(java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
catalog
- 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 occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
catalog
- 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 schema
DatabaseOperationException
public void alterTables(java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
catalog
- 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 occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
catalog
- 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 creation
DatabaseOperationException
public void alterTables(java.sql.Connection connection, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
connection
- 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 occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.sql.Connection connection, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
connection
- 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 schema
DatabaseOperationException
public void alterTables(java.sql.Connection connection, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, CreationParameters params, boolean continueOnError) throws DatabaseOperationException
alterTables
in interface Platform
connection
- 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 occurred
DatabaseOperationException
public java.lang.String getAlterTablesSql(java.sql.Connection connection, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes, Database desiredModel, CreationParameters params) throws DatabaseOperationException
getAlterTablesSql
in interface Platform
connection
- 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 creation
DatabaseOperationException
public void dropTable(java.sql.Connection connection, Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable
in interface Platform
connection
- The connection to the databasemodel
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public void dropTable(Database model, Table table, boolean continueOnError) throws DatabaseOperationException
dropTable
in interface Platform
model
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public java.lang.String getDropTableSql(Database model, Table table, boolean continueOnError)
getDropTableSql
in interface Platform
model
- The database modeltable
- The table to dropcontinueOnError
- Whether to continue executing the sql commands when an error occurred
public void dropTables(Database model, boolean continueOnError) throws DatabaseOperationException
dropTables
in interface Platform
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public void dropTables(java.sql.Connection connection, Database model, boolean continueOnError) throws DatabaseOperationException
dropTables
in interface Platform
connection
- The connection to the databasemodel
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DatabaseOperationException
public java.lang.String getDropTablesSql(Database model, boolean continueOnError)
getDropTablesSql
in interface Platform
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
public java.util.Iterator query(Database model, java.lang.String sql) throws DatabaseOperationException
query
in interface Platform
model
- The database model to usesql
- The sql query to perform
DatabaseOperationException
public java.util.Iterator query(Database model, java.lang.String sql, java.util.Collection parameters) throws DatabaseOperationException
query
in interface Platform
model
- The database model to usesql
- The sql query to performparameters
- The query parameter values
DatabaseOperationException
public java.util.Iterator query(Database model, java.lang.String sql, Table[] queryHints) throws DatabaseOperationException
query
in interface Platform
model
- The database model to usesql
- The sql query to performqueryHints
- The tables that are queried (optional)
DatabaseOperationException
public java.util.Iterator query(Database model, java.lang.String sql, java.util.Collection parameters, Table[] queryHints) throws DatabaseOperationException
query
in interface Platform
model
- The database model to usesql
- The sql query to performparameters
- The query parameter valuesqueryHints
- The tables that are queried (optional)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.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 Platform
model
- The database model to usesql
- The sql query
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.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 Platform
model
- The database model to usesql
- The sql queryqueryHints
- The tables that are queried (optional)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.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 Platform
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)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.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 Platform
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)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.String sql, java.util.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 Platform
model
- The database model to usesql
- The parameterized queryparameters
- The parameter values
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.String sql, java.util.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 Platform
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)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.String sql, java.util.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 Platform
model
- The database model to usesql
- The parameterized queryparameters
- The parameter valuesqueryHints
- The tables that are queried (optional)
DatabaseOperationException
public java.util.List fetch(Database model, java.lang.String sql, java.util.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 Platform
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)
DatabaseOperationException
protected java.lang.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 insert
protected java.lang.String createSelectLastInsertIdSql(Database model, SqlDynaClass dynaClass)
model
- The database modeldynaClass
- The type
null
if the database does not
support thispublic java.lang.String getInsertSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getInsertSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void insert(java.sql.Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean
DatabaseOperationException
public void insert(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
insert
in interface Platform
model
- The database model to usedynaBean
- The bean to insert
DatabaseOperationException
public void insert(java.sql.Connection connection, Database model, java.util.Collection dynaBeans) throws DatabaseOperationException
insert
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBeans
- The beans
DatabaseOperationException
public void insert(Database model, java.util.Collection dynaBeans) throws DatabaseOperationException
insert
in interface Platform
model
- The database model to usedynaBeans
- The beans to insert
DatabaseOperationException
protected void beforeInsert(java.sql.Connection connection, Table table) throws java.sql.SQLException
connection
- The connection used for the insertiontable
- The table that the rows are inserted into
java.sql.SQLException
protected void afterInsert(java.sql.Connection connection, Table table) throws java.sql.SQLException
connection
- The connection used for the insertiontable
- The table that the rows have been inserted into
java.sql.SQLException
protected java.lang.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 update
public java.lang.String getUpdateSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getUpdateSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void update(java.sql.Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean
DatabaseOperationException
public void update(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
update
in interface Platform
model
- The database model to usedynaBean
- The bean
DatabaseOperationException
protected void beforeUpdate(java.sql.Connection connection, Table table) throws java.sql.SQLException
connection
- The connection used for the updatetable
- The table that the rows are updateed into
java.sql.SQLException
protected void afterUpdate(java.sql.Connection connection, Table table) throws java.sql.SQLException
connection
- The connection used for the updatetable
- The table that the rows have been updateed into
java.sql.SQLException
protected boolean exists(java.sql.Connection connection, org.apache.commons.beanutils.DynaBean dynaBean)
dynaBean
- The beanconnection
- The connection
true
if this dyna bean has a primary keypublic void store(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
store
in interface Platform
model
- The database model to usedynaBean
- The bean to store
DatabaseOperationException
protected java.lang.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 update
public java.lang.String getDeleteSql(Database model, org.apache.commons.beanutils.DynaBean dynaBean)
getDeleteSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void delete(Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete
in interface Platform
model
- The database model to usedynaBean
- The bean to delete
DatabaseOperationException
public void delete(java.sql.Connection connection, Database model, org.apache.commons.beanutils.DynaBean dynaBean) throws DatabaseOperationException
delete
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean
DatabaseOperationException
public Database readModelFromDatabase(java.lang.String name) throws DatabaseOperationException
readModelFromDatabase
in interface Platform
name
- The name of the resulting database; null
when the default name (the catalog)
is desired which might be null
itself though
DatabaseOperationException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(java.sql.Connection connection, java.lang.String name) throws DatabaseOperationException
readModelFromDatabase
in interface Platform
connection
- 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 though
DatabaseOperationException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(java.lang.String name, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase
in interface Platform
name
- 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 ones
DatabaseOperationException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(java.sql.Connection connection, java.lang.String name, java.lang.String catalog, java.lang.String schema, java.lang.String[] tableTypes) throws DatabaseOperationException
readModelFromDatabase
in interface Platform
connection
- 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 ones
DatabaseOperationException
- If an error occurred during reading the modelprotected void postprocessModelFromDatabase(Database model)
model
- The modelprotected java.util.HashMap toColumnValues(SqlDynaProperty[] properties, org.apache.commons.beanutils.DynaBean bean)
properties
- The propertiesbean
- The bean
protected void setObject(java.sql.PreparedStatement statement, int sqlIndex, org.apache.commons.beanutils.DynaBean dynaBean, SqlDynaProperty property) throws java.sql.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 column
java.sql.SQLException
protected void setStatementParameterValue(java.sql.PreparedStatement statement, int sqlIndex, int typeCode, java.lang.Object value) throws java.sql.SQLException
statement
- The statementsqlIndex
- The parameter indextypeCode
- The JDBC type codevalue
- The value
java.sql.SQLException
- If an error occurred while setting the parameter valueprotected java.lang.Object getObjectFromResultSet(java.sql.ResultSet resultSet, java.lang.String columnName, Table table) throws java.sql.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 table
java.sql.SQLException
protected java.lang.Object getObjectFromResultSet(java.sql.ResultSet resultSet, Column column, int idx) throws java.sql.SQLException
resultSet
- The result setcolumn
- The columnidx
- The value's index in the result set (starting from 1)
java.sql.SQLException
protected java.lang.Object extractColumnValue(java.sql.ResultSet resultSet, java.lang.String columnName, int columnIdx, int jdbcType) throws java.sql.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 null
jdbcType
- The jdbc type to extract
java.sql.SQLException
- If an error occurred while accessing the result setprotected ModelBasedResultSetIterator createResultSetIterator(Database model, java.sql.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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |