org.apache.ddlutils.platform
Class PlatformImplBase

java.lang.Object
  extended byorg.apache.ddlutils.util.JdbcSupport
      extended byorg.apache.ddlutils.platform.PlatformImplBase
All Implemented Interfaces:
Platform
Direct Known Subclasses:
AxionPlatform, CloudscapePlatform, Db2Platform, FirebirdPlatform, HsqlDbPlatform, InterbasePlatform, MckoiPlatform, MSSqlPlatform, MySql50Platform, MySqlPlatform, Oracle8Platform, PostgreSqlPlatform, SapDbPlatform, SybasePlatform

public abstract class PlatformImplBase
extends JdbcSupport
implements Platform

Base class for platform implementations.

Version:
$Revision: 231110 $
Author:
James Strachan, Thomas Dudziak

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

PlatformImplBase

public PlatformImplBase()
Method Detail

getSqlBuilder

public SqlBuilder getSqlBuilder()
Returns the sql builder for the this platform.

Specified by:
getSqlBuilder in interface Platform
Returns:
The sql builder

setSqlBuilder

protected void setSqlBuilder(SqlBuilder builder)
Sets the sql builder for this platform.

Parameters:
builder - The sql builder

getModelReader

public JdbcModelReader getModelReader()
Returns the model reader (which reads a database model from a live database) for this platform.

Specified by:
getModelReader in interface Platform
Returns:
The model reader

setModelReader

protected void setModelReader(JdbcModelReader modelReader)
Sets the model reader for this platform.

Parameters:
modelReader - The model reader

getPlatformInfo

public PlatformInfo getPlatformInfo()
Returns the info object for this platform.

Specified by:
getPlatformInfo in interface Platform
Returns:
The info object

getLog

protected org.apache.commons.logging.Log getLog()
Returns the log for this platform.

Returns:
The log

logWarnings

protected void logWarnings(Connection connection)
                    throws SQLException
Logs any warnings associated to the given connection. Note that the connection needs to be open for this.

Parameters:
connection - The open connection
Throws:
SQLException

evaluateBatch

public int evaluateBatch(String sql,
                         boolean continueOnError)
                  throws DynaSqlException
Executes a series of sql statements which must be seperated by the delimiter configured as PlatformInfo.getSqlCommandDelimiter() of the info object of this platform.

Specified by:
evaluateBatch in interface Platform
Parameters:
sql - The sql statements to execute
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The number of errors
Throws:
DynaSqlException

evaluateBatch

public int evaluateBatch(Connection connection,
                         String sql,
                         boolean continueOnError)
                  throws DynaSqlException
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

Specified by:
evaluateBatch in interface Platform
Parameters:
connection - The connection to the database
sql - The sql statements to execute
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The number of errors
Throws:
DynaSqlException

shutdownDatabase

public void shutdownDatabase()
                      throws DynaSqlException
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.

Specified by:
shutdownDatabase in interface Platform
Throws:
DynaSqlException

shutdownDatabase

public void shutdownDatabase(Connection connection)
                      throws DynaSqlException
Performs a shutdown at the database. This is necessary for some embedded databases which otherwise would be locked and thus would refuse other connections. Note that this does not change the database structure or data in it in any way.

Specified by:
shutdownDatabase in interface Platform
Parameters:
connection - The connection to the database
Throws:
DynaSqlException

createDatabase

public void createDatabase(String jdbcDriverClassName,
                           String connectionUrl,
                           String username,
                           String password,
                           Map parameters)
                    throws DynaSqlException,
                           UnsupportedOperationException
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.

Specified by:
createDatabase in interface Platform
Parameters:
jdbcDriverClassName - The jdbc driver class name
connectionUrl - The url to connect to the database if it were already created
username - The username for creating the database
password - The password for creating the database
parameters - Additional parameters relevant to database creation (which are platform specific)
Throws:
DynaSqlException
UnsupportedOperationException

dropDatabase

public void dropDatabase(String jdbcDriverClassName,
                         String connectionUrl,
                         String username,
                         String password)
                  throws DynaSqlException,
                         UnsupportedOperationException
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.

Specified by:
dropDatabase in interface Platform
Parameters:
jdbcDriverClassName - The jdbc driver class name
connectionUrl - The url to connect to the database
username - The username for creating the database
password - The password for creating the database
Throws:
DynaSqlException
UnsupportedOperationException

createTables

public void createTables(Database model,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
Creates the tables defined in the database model.

Specified by:
createTables in interface Platform
Parameters:
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

createTables

public void createTables(Connection connection,
                         Database model,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
Creates the tables defined in the database model.

Specified by:
createTables in interface Platform
Parameters:
connection - The connection to the database
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

getCreateTablesSql

public String getCreateTablesSql(Database model,
                                 boolean dropTablesFirst,
                                 boolean continueOnError)
                          throws DynaSqlException
Returns the SQL for creating the tables defined in the database model.

Specified by:
getCreateTablesSql in interface Platform
Parameters:
model - The database model
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

createTables

public void createTables(Database model,
                         CreationParameters params,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
Creates the tables defined in the database model.

Specified by:
createTables in interface Platform
Parameters:
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

createTables

public void createTables(Connection connection,
                         Database model,
                         CreationParameters params,
                         boolean dropTablesFirst,
                         boolean continueOnError)
                  throws DynaSqlException
Creates the tables defined in the database model.

Specified by:
createTables in interface Platform
Parameters:
connection - The connection to the database
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

getCreateTablesSql

public String getCreateTablesSql(Database model,
                                 CreationParameters params,
                                 boolean dropTablesFirst,
                                 boolean continueOnError)
                          throws DynaSqlException
Returns the SQL for creating the tables defined in the database model.

Specified by:
getCreateTablesSql in interface Platform
Parameters:
model - The database model
params - The parameters used in the creation
dropTablesFirst - Whether to drop the tables prior to creating them (anew)
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Database desiredDb,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
desiredDb - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Database desiredDb,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
desiredDb - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Database desiredDb,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
desiredDb - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Database desiredDb,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
desiredDb - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        Database desiredModel,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                Database desiredModel,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        Database desiredModel,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                Database desiredModel,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredModel,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredModel,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredModel,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredModel,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredModel,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredModel,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

alterTables

public void alterTables(Connection connection,
                        String catalog,
                        String schema,
                        String[] tableTypes,
                        Database desiredModel,
                        CreationParameters params,
                        boolean doDrops,
                        boolean modifyColumns,
                        boolean continueOnError)
                 throws DynaSqlException
Alters the database schema so that it match the given model.

Specified by:
alterTables in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Throws:
DynaSqlException

getAlterTablesSql

public String getAlterTablesSql(Connection connection,
                                String catalog,
                                String schema,
                                String[] tableTypes,
                                Database desiredModel,
                                CreationParameters params,
                                boolean doDrops,
                                boolean modifyColumns,
                                boolean continueOnError)
                         throws DynaSqlException
Returns the SQL for altering the database schema so that it match the given model.

Specified by:
getAlterTablesSql in interface Platform
Parameters:
connection - A connection to the existing database that shall be modified
catalog - The catalog in the existing database to read (can be a pattern); use null for the platform-specific default value
schema - The schema in the existing database to read (can be a pattern); use null for the platform-specific default value
tableTypes - The table types to read from the existing database; use null or an empty array for the platform-specific default value
desiredModel - The desired database schema
params - The parameters used in the creation
doDrops - Whether columns, tables and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
continueOnError - Whether to continue with the next sql statement when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

dropTables

public void dropTables(Database model,
                       boolean continueOnError)
                throws DynaSqlException
Drops the tables defined in the given database.

Specified by:
dropTables in interface Platform
Parameters:
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

dropTables

public void dropTables(Connection connection,
                       Database model,
                       boolean continueOnError)
                throws DynaSqlException
Drops the tables defined in the given database.

Specified by:
dropTables in interface Platform
Parameters:
connection - The connection to the database
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Throws:
DynaSqlException

getDropTablesSql

public String getDropTablesSql(Database model,
                               boolean continueOnError)
                        throws DynaSqlException
Returns the SQL for dropping the tables defined in the given database.

Specified by:
getDropTablesSql in interface Platform
Parameters:
model - The database model
continueOnError - Whether to continue executing the sql commands when an error occurred
Returns:
The SQL statements
Throws:
DynaSqlException

query

public Iterator query(Database model,
                      String sql)
               throws DynaSqlException
Performs the given SQL query returning an iterator over the results.

Specified by:
query in interface Platform
Parameters:
model - The database model to use
sql - The sql query to perform
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Collection parameters)
               throws DynaSqlException
Performs the given parameterized SQL query returning an iterator over the results.

Specified by:
query in interface Platform
Parameters:
model - The database model to use
sql - The sql query to perform
parameters - The query parameter values
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Table[] queryHints)
               throws DynaSqlException
Performs the given SQL query returning an iterator over the results.

Specified by:
query in interface Platform
Parameters:
model - The database model to use
sql - The sql query to perform
queryHints - The tables that are queried (optional)
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DynaSqlException

query

public Iterator query(Database model,
                      String sql,
                      Collection parameters,
                      Table[] queryHints)
               throws DynaSqlException
Performs the given parameterized SQL query returning an iterator over the results.

Specified by:
query in interface Platform
Parameters:
model - The database model to use
sql - The sql query to perform
parameters - The query parameter values
queryHints - The tables that are queried (optional)
Returns:
An iterator for the dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql)
           throws DynaSqlException
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.

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The sql query
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Table[] queryHints)
           throws DynaSqlException
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.

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The sql query
queryHints - The tables that are queried (optional)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  int start,
                  int end)
           throws DynaSqlException
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).

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The sql query
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Table[] queryHints,
                  int start,
                  int end)
           throws DynaSqlException
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).

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The sql query
queryHints - The tables that are queried (optional)
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters)
           throws DynaSqlException
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.

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The parameterized query
parameters - The parameter values
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  int start,
                  int end)
           throws DynaSqlException
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).

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The parameterized sql query
parameters - The parameter values
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  Table[] queryHints)
           throws DynaSqlException
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.

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The parameterized query
parameters - The parameter values
queryHints - The tables that are queried (optional)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

fetch

public List fetch(Database model,
                  String sql,
                  Collection parameters,
                  Table[] queryHints,
                  int start,
                  int end)
           throws DynaSqlException
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).

Specified by:
fetch in interface Platform
Parameters:
model - The database model to use
sql - The parameterized sql query
parameters - The parameter values
queryHints - The tables that are queried (optional)
start - Row number to start from (0 for first row)
end - Row number to stop at (inclusively; -1 for last row)
Returns:
The dyna beans resulting from the query
Throws:
DynaSqlException

createInsertSql

protected String createInsertSql(Database model,
                                 SqlDynaClass dynaClass,
                                 SqlDynaProperty[] properties,
                                 DynaBean bean)
Creates the SQL for inserting an object of the given type. If a concrete bean is given, then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.

Parameters:
model - The database model
dynaClass - The type
properties - The properties to write
bean - Optionally the concrete bean to insert
Returns:
The SQL required to insert an instance of the class

createSelectLastInsertIdSql

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.

Parameters:
model - The database model
dynaClass - The type
Returns:
The SQL required for querying for the id, or null if the database does not support this

getInsertSql

public String getInsertSql(Database model,
                           DynaBean dynaBean)
Returns the sql for inserting the given bean.

Specified by:
getInsertSql in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The insert sql

insert

public void insert(Connection connection,
                   Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Inserts the bean. If one of the columns is an auto-incremented column, then the bean will also be updated with the column value generated by the database. Note that the connection will not be closed by this method.

Specified by:
insert in interface Platform
Parameters:
connection - The database connection
model - The database model to use
dynaBean - The bean
Throws:
DynaSqlException

insert

public void insert(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Inserts the given DynaBean in the database, assuming the primary key values are specified.

Specified by:
insert in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean to insert
Throws:
DynaSqlException

insert

public void insert(Connection connection,
                   Database model,
                   Collection dynaBeans)
            throws DynaSqlException
Inserts the given beans. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint). This method does not close the connection.

Specified by:
insert in interface Platform
Parameters:
connection - The database connection
model - The database model to use
dynaBeans - The beans
Throws:
DynaSqlException

insert

public void insert(Database model,
                   Collection dynaBeans)
            throws DynaSqlException
Inserts the given beans in the database, assuming the primary key values are specified. Note that a batch insert is used for subsequent beans of the same type. Also the properties for the primary keys are not updated in the beans. Hence you should not use this method when the primary key values are defined by the database (via a sequence or identity constraint).

Specified by:
insert in interface Platform
Parameters:
model - The database model to use
dynaBeans - The beans to insert
Throws:
DynaSqlException

createUpdateSql

protected String createUpdateSql(Database model,
                                 SqlDynaClass dynaClass,
                                 SqlDynaProperty[] primaryKeys,
                                 SqlDynaProperty[] properties,
                                 DynaBean bean)
Creates the SQL for updating an object of the given type. If a concrete bean is given, then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.

Parameters:
model - The database model
dynaClass - The type
primaryKeys - The primary keys
properties - The properties to write
bean - Optionally the concrete bean to update
Returns:
The SQL required to update the instance

getUpdateSql

public String getUpdateSql(Database model,
                           DynaBean dynaBean)
Returns the sql for updating the given bean in the database.

Specified by:
getUpdateSql in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The update sql

update

public void update(Connection connection,
                   Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Updates the row which maps to the given bean.

Specified by:
update in interface Platform
Parameters:
connection - The database connection
model - The database model to use
dynaBean - The bean
Throws:
DynaSqlException

update

public void update(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Updates the given bean in the database, assuming the primary key values are specified.

Specified by:
update in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean
Throws:
DynaSqlException

exists

protected boolean exists(Connection connection,
                         DynaBean dynaBean)
Determines whether the given dyna bean is stored in the database.

Parameters:
dynaBean - The bean
connection - The connection
Returns:
true if this dyna bean has a primary key

store

public void store(Database model,
                  DynaBean dynaBean)
           throws DynaSqlException
Stores the given bean in the database, inserting it if there is no primary key otherwise the bean is updated in the database.

Specified by:
store in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean to store
Throws:
DynaSqlException

createDeleteSql

protected String createDeleteSql(Database model,
                                 SqlDynaClass dynaClass,
                                 SqlDynaProperty[] primaryKeys,
                                 DynaBean bean)
Creates the SQL for deleting an object of the given type. If a concrete bean is given, then a concrete delete statement is created, otherwise a delete statement usable in a prepared statement is build.

Parameters:
model - The database model
dynaClass - The type
primaryKeys - The primary keys
bean - Optionally the concrete bean to update
Returns:
The SQL required to delete the instance

getDeleteSql

public String getDeleteSql(Database model,
                           DynaBean dynaBean)
Returns the sql for deleting the given bean from the database.

Specified by:
getDeleteSql in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean
Returns:
The sql

delete

public void delete(Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Deletes the given bean from the database, assuming the primary key values are specified.

Specified by:
delete in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean to delete
Throws:
DynaSqlException

delete

public void delete(Connection connection,
                   Database model,
                   DynaBean dynaBean)
            throws DynaSqlException
Deletes the row which maps to the given bean from the database.

Specified by:
delete in interface Platform
Parameters:
model - The database model to use
dynaBean - The bean
connection - The database connection
Throws:
DynaSqlException

readModelFromDatabase

public Database readModelFromDatabase(String name)
                               throws DynaSqlException
Reads the database model from the live database as specified by the data source set for this platform.

Specified by:
readModelFromDatabase in interface Platform
Parameters:
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
Returns:
The database model
Throws:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(Connection connection,
                                      String name)
                               throws DynaSqlException
Reads the database model from the live database to which the given connection is pointing.

Specified by:
readModelFromDatabase in interface Platform
Parameters:
connection - The connection to the database
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
Returns:
The database model
Throws:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(String name,
                                      String catalog,
                                      String schema,
                                      String[] tableTypes)
                               throws DynaSqlException
Reads the database model from the live database as specified by the data source set for this platform.

Specified by:
readModelFromDatabase in interface Platform
Parameters:
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
catalog - The catalog to access in the database; use null for the default value
schema - The schema to access in the database; use null for the default value
tableTypes - The table types to process; use null or an empty list for the default ones
Returns:
The database model
Throws:
DynaSqlException - If an error occurred during reading the model

readModelFromDatabase

public Database readModelFromDatabase(Connection connection,
                                      String name,
                                      String catalog,
                                      String schema,
                                      String[] tableTypes)
                               throws DynaSqlException
Reads the database model from the live database to which the given connection is pointing.

Specified by:
readModelFromDatabase in interface Platform
Parameters:
connection - The connection to the database
name - The name of the resulting database; null when the default name (the catalog) is desired which might be null itself though
catalog - The catalog to access in the database; use null for the default value
schema - The schema to access in the database; use null for the default value
tableTypes - The table types to process; use null or an empty list for the default ones
Returns:
The database model
Throws:
DynaSqlException - If an error occurred during reading the model

postprocessModelFromDatabase

protected void postprocessModelFromDatabase(Database model)
Allows the platform to postprocess the model just read from the database.

Parameters:
model - The model

toColumnValues

protected HashMap toColumnValues(SqlDynaProperty[] properties,
                                 DynaBean bean)
Derives the column values for the given dyna properties from the dyna bean.

Parameters:
properties - The properties
bean - The bean
Returns:
The values indexed by the column names

setObject

protected void setObject(PreparedStatement statement,
                         int sqlIndex,
                         DynaBean dynaBean,
                         SqlDynaProperty property)
                  throws SQLException
Sets a parameter of the prepared statement based on the type of the column of the property.

Parameters:
statement - The statement
sqlIndex - The index of the parameter to set in the statement
dynaBean - The bean of which to take the value
property - The property of the bean, which also defines the corresponding column
Throws:
SQLException

getObjectFromResultSet

protected Object getObjectFromResultSet(ResultSet resultSet,
                                        String columnName,
                                        Table table)
                                 throws SQLException
Helper method esp. for the 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.
The method is defined here rather than in the ModelBasedResultSetIterator class so that concrete platforms can modify its behavior.

Parameters:
resultSet - The result set
columnName - The name of the column
table - The table
Returns:
The value
Throws:
SQLException

createResultSetIterator

protected ModelBasedResultSetIterator createResultSetIterator(Database model,
                                                              ResultSet resultSet,
                                                              Table[] queryHints)
Creates an iterator over the given result set.

Parameters:
model - The database model
resultSet - The result set to iterate over
queryHints - The tables that were queried in the query that produced the given result set (optional)
Returns:
The iterator


Copyright © 2005 Apache Software Foundation. All Rights Reserved.