|
||||||||||
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
Base class for platform implementations.
Constructor Summary | |
PlatformImplBase()
|
Method Summary | |
void |
alterTables(Connection connection,
Database desiredModel,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(Connection connection,
Database desiredModel,
CreationParameters params,
boolean doDrops,
boolean modifyColumns,
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 doDrops,
boolean modifyColumns,
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 doDrops,
boolean modifyColumns,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(Database desiredDb,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(Database desiredDb,
CreationParameters params,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
alterTables(String catalog,
String schema,
String[] tableTypes,
Database desiredModel,
boolean doDrops,
boolean modifyColumns,
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 doDrops,
boolean modifyColumns,
boolean continueOnError)
Alters the database schema so that it match the given model. |
void |
createDatabase(String jdbcDriverClassName,
String connectionUrl,
String username,
String password,
Map parameters)
Creates the database specified by the given parameters. Please note that this method does not use a data source set via Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection.The given connection url is the url that you'd use to connect to the already-created database. On some platforms, this method suppurts additional parameters. These are documented in the manual section for the individual platforms. |
protected String |
createDeleteSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] primaryKeys,
DynaBean bean)
Creates the SQL for deleting an object of the given type. |
protected String |
createInsertSql(Database model,
SqlDynaClass dynaClass,
SqlDynaProperty[] properties,
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,
DynaBean bean)
Creates the SQL for updating an object of the given type. |
void |
delete(Connection connection,
Database model,
DynaBean dynaBean)
Deletes the row which maps to the given bean from the database. |
void |
delete(Database model,
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. Please note that this method does not use a data source set via Platform.setDataSource(DataSource) because it is not possible to
retrieve the connection information from it without establishing a connection. |
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.
TODO: consider outputting a collection of String or some kind of statement
object from the SqlBuilder instead of having to parse strings here |
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,
DynaBean dynaBean)
Determines whether the given dyna bean is stored in the database. |
List |
fetch(Database model,
String sql)
Queries for a list of dyna beans representing rows of the given query. In contrast to the Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans. |
List |
fetch(Database model,
String sql,
Collection parameters)
Queries for a list of dyna beans representing rows of the given query. In contrast to the Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans. |
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. In contrast to the 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). |
List |
fetch(Database model,
String sql,
Collection parameters,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query. In contrast to the Platform.query(Database, String, Collection) method
all beans will be materialized and the connection will be closed before
returning the beans. |
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. In contrast to the 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). |
List |
fetch(Database model,
String sql,
int start,
int end)
Queries for a list of dyna beans representing rows of the given query. In contrast to the 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). |
List |
fetch(Database model,
String sql,
Table[] queryHints)
Queries for a list of dyna beans representing rows of the given query. In contrast to the Platform.query(Database, String) method all beans will be
materialized and the connection will be closed before returning the beans. |
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. In contrast to the 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). |
String |
getAlterTablesSql(Connection connection,
Database desiredModel,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Returns the SQL for altering the database schema so that it match the given model. |
String |
getAlterTablesSql(Connection connection,
Database desiredModel,
CreationParameters params,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
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,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
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,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Returns the SQL for altering the database schema so that it match the given model. |
String |
getAlterTablesSql(Database desiredDb,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
Returns the SQL for altering the database schema so that it match the given model. |
String |
getAlterTablesSql(Database desiredDb,
CreationParameters params,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
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,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
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,
boolean doDrops,
boolean modifyColumns,
boolean continueOnError)
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,
DynaBean dynaBean)
Returns the sql for deleting the given bean from the database. |
String |
getDropTablesSql(Database model,
boolean continueOnError)
Returns the SQL for dropping the tables defined in the given database. |
String |
getInsertSql(Database model,
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,
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,
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. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint). This method does not close the connection. |
void |
insert(Connection connection,
Database model,
DynaBean dynaBean)
Inserts the bean. If one of the columns is an auto-incremented column, then the bean will also be updated with the column value generated by the database. Note that the connection will not be closed by this method. |
void |
insert(Database model,
Collection dynaBeans)
Inserts the given beans in the database, assuming the primary key values are specified. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint). |
void |
insert(Database model,
DynaBean dynaBean)
Inserts the given DynaBean in the database, assuming the primary key values are specified. |
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. |
protected void |
setModelReader(JdbcModelReader modelReader)
Sets the model reader for this platform. |
protected void |
setObject(PreparedStatement statement,
int sqlIndex,
DynaBean dynaBean,
SqlDynaProperty property)
Sets a parameter of the prepared statement based on the type of the column of the property. |
protected void |
setSqlBuilder(SqlBuilder builder)
Sets the sql builder for this platform. |
void |
shutdownDatabase()
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way. |
void |
shutdownDatabase(Connection connection)
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way. |
void |
store(Database model,
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,
DynaBean bean)
Derives the column values for the given dyna properties from the dyna bean. |
void |
update(Connection connection,
Database model,
DynaBean dynaBean)
Updates the row which maps to the given bean. |
void |
update(Database model,
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 |
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
protected org.apache.commons.logging.Log getLog()
protected void logWarnings(Connection connection) throws SQLException
connection
- The open connection
SQLException
public int evaluateBatch(String sql, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public void shutdownDatabase() throws DynaSqlException
shutdownDatabase
in interface Platform
DynaSqlException
public void shutdownDatabase(Connection connection) throws DynaSqlException
shutdownDatabase
in interface Platform
connection
- The connection to the database
DynaSqlException
public void createDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password, Map parameters) throws DynaSqlException, 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)
DynaSqlException
UnsupportedOperationException
public void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username, String password) throws DynaSqlException, 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
DynaSqlException
UnsupportedOperationException
public void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public void createTables(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public void createTables(Connection connection, Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException
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
DynaSqlException
public void alterTables(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
alterTables
in interface Platform
desiredDb
- The desired database schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
getAlterTablesSql
in interface Platform
desiredDb
- The desired database schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
alterTables
in interface Platform
desiredDb
- The desired database schemaparams
- The parameters used in the creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Database desiredDb, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
getAlterTablesSql
in interface Platform
desiredDb
- The desired database schemaparams
- The parameters used in the creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(Connection connection, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
alterTables
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Connection connection, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
getAlterTablesSql
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(Connection connection, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
alterTables
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemaparams
- The parameters used in the creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Connection connection, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
getAlterTablesSql
in interface Platform
connection
- A connection to the existing database that shall be modifieddesiredModel
- The desired database schemaparams
- The parameters used in the creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 schemadoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void alterTables(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public String getAlterTablesSql(Connection connection, String catalog, String schema, String[] tableTypes, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException
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 creationdoDrops
- Whether columns, tables and indexes should be dropped if not in the
new schemamodifyColumns
- Whether columns should be altered for datatype, size as requiredcontinueOnError
- Whether to continue with the next sql statement when an error occurred
DynaSqlException
public void dropTables(Database model, boolean continueOnError) throws DynaSqlException
dropTables
in interface Platform
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DynaSqlException
public void dropTables(Connection connection, Database model, boolean continueOnError) throws DynaSqlException
dropTables
in interface Platform
connection
- The connection to the databasemodel
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DynaSqlException
public String getDropTablesSql(Database model, boolean continueOnError) throws DynaSqlException
getDropTablesSql
in interface Platform
model
- The database modelcontinueOnError
- Whether to continue executing the sql commands when an error occurred
DynaSqlException
public Iterator query(Database model, String sql) throws DynaSqlException
query
in interface Platform
model
- The database model to usesql
- The sql query to perform
DynaSqlException
public Iterator query(Database model, String sql, Collection parameters) throws DynaSqlException
query
in interface Platform
model
- The database model to usesql
- The sql query to performparameters
- The query parameter values
DynaSqlException
public Iterator query(Database model, String sql, Table[] queryHints) throws DynaSqlException
query
in interface Platform
model
- The database model to usesql
- The sql query to performqueryHints
- The tables that are queried (optional)
DynaSqlException
public Iterator query(Database model, String sql, Collection parameters, Table[] queryHints) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql) throws DynaSqlException
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
DynaSqlException
public List fetch(Database model, String sql, Table[] queryHints) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql, int start, int end) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql, Table[] queryHints, int start, int end) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql, Collection parameters) throws DynaSqlException
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
DynaSqlException
public List fetch(Database model, String sql, Collection parameters, int start, int end) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql, Collection parameters, Table[] queryHints) throws DynaSqlException
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)
DynaSqlException
public List fetch(Database model, String sql, Collection parameters, Table[] queryHints, int start, int end) throws DynaSqlException
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)
DynaSqlException
protected String createInsertSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] properties, DynaBean bean)
model
- The database modeldynaClass
- The typeproperties
- The properties to writebean
- Optionally the concrete bean to insert
protected String createSelectLastInsertIdSql(Database model, SqlDynaClass dynaClass)
model
- The database modeldynaClass
- The type
null
if the database does not
support thispublic String getInsertSql(Database model, DynaBean dynaBean)
getInsertSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void insert(Connection connection, Database model, DynaBean dynaBean) throws DynaSqlException
insert
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean
DynaSqlException
public void insert(Database model, DynaBean dynaBean) throws DynaSqlException
insert
in interface Platform
model
- The database model to usedynaBean
- The bean to insert
DynaSqlException
public void insert(Connection connection, Database model, Collection dynaBeans) throws DynaSqlException
insert
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBeans
- The beans
DynaSqlException
public void insert(Database model, Collection dynaBeans) throws DynaSqlException
insert
in interface Platform
model
- The database model to usedynaBeans
- The beans to insert
DynaSqlException
protected String createUpdateSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, SqlDynaProperty[] properties, DynaBean bean)
model
- The database modeldynaClass
- The typeprimaryKeys
- The primary keysproperties
- The properties to writebean
- Optionally the concrete bean to update
public String getUpdateSql(Database model, DynaBean dynaBean)
getUpdateSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void update(Connection connection, Database model, DynaBean dynaBean) throws DynaSqlException
update
in interface Platform
connection
- The database connectionmodel
- The database model to usedynaBean
- The bean
DynaSqlException
public void update(Database model, DynaBean dynaBean) throws DynaSqlException
update
in interface Platform
model
- The database model to usedynaBean
- The bean
DynaSqlException
protected boolean exists(Connection connection, DynaBean dynaBean)
dynaBean
- The beanconnection
- The connection
true
if this dyna bean has a primary keypublic void store(Database model, DynaBean dynaBean) throws DynaSqlException
store
in interface Platform
model
- The database model to usedynaBean
- The bean to store
DynaSqlException
protected String createDeleteSql(Database model, SqlDynaClass dynaClass, SqlDynaProperty[] primaryKeys, DynaBean bean)
model
- The database modeldynaClass
- The typeprimaryKeys
- The primary keysbean
- Optionally the concrete bean to update
public String getDeleteSql(Database model, DynaBean dynaBean)
getDeleteSql
in interface Platform
model
- The database model to usedynaBean
- The bean
public void delete(Database model, DynaBean dynaBean) throws DynaSqlException
delete
in interface Platform
model
- The database model to usedynaBean
- The bean to delete
DynaSqlException
public void delete(Connection connection, Database model, DynaBean dynaBean) throws DynaSqlException
delete
in interface Platform
model
- The database model to usedynaBean
- The beanconnection
- The database connection
DynaSqlException
public Database readModelFromDatabase(String name) throws DynaSqlException
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
DynaSqlException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name) throws DynaSqlException
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
DynaSqlException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(String name, String catalog, String schema, String[] tableTypes) throws DynaSqlException
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
DynaSqlException
- If an error occurred during reading the modelpublic Database readModelFromDatabase(Connection connection, String name, String catalog, String schema, String[] tableTypes) throws DynaSqlException
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
DynaSqlException
- If an error occurred during reading the modelprotected void postprocessModelFromDatabase(Database model)
model
- The modelprotected HashMap toColumnValues(SqlDynaProperty[] properties, DynaBean bean)
properties
- The propertiesbean
- The bean
protected void setObject(PreparedStatement statement, int sqlIndex, 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 column
SQLException
protected 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 table
SQLException
protected 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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |