org.xorm.datastore.sql
Class BaseSQLDriver

java.lang.Object
  |
  +--org.xorm.datastore.sql.BaseSQLDriver
All Implemented Interfaces:
DatastoreDriver, I15d
Direct Known Subclasses:
SybaseDriver

public class BaseSQLDriver
extends Object
implements DatastoreDriver, I15d

Implements the datastore driver interface for a "plain vanilla" generic JDBC driver. The implementation is configured by the drivers.properties file, which maps particular idioms for handling sequences and autoincrement columns to particular JDBC driver classes. This is intended to handle all JDBC drivers that work according to the specification; subclasses should be necessary only for databases that behave in odd or non-standard ways.


Nested Class Summary
 class BaseSQLDriver.PreparedStatements
           
 
Field Summary
protected  SQLConnectionInfo connectionInfo
           
protected  Connection currentConnection
           
protected  DataSource dataSource
           
protected  Logger logger
           
protected  boolean readOnly
           
 
Fields inherited from interface org.xorm.I15d
I18N
 
Constructor Summary
BaseSQLDriver()
           
 
Method Summary
 void begin(boolean readOnly)
           
 void commit()
           
 int count(Selector selector)
          Returns the size of the results that would be returned by the query.
 void create(Row row)
          Creates (inserts) a new row in the datastore.
protected  BaseSQLDriver.PreparedStatements createPreparedStatements(Table table)
          Subclasses should override this if they need to provide custom SQL generation for the prepared statements.
 void delete(Row row)
          Permanently deletes a single row from the datastore.
protected  BaseSQLDriver.PreparedStatements getStatements(Table table)
           
protected  boolean inTransaction()
           
 void rollback()
           
 Collection select(Selector selector, Set extraRows)
          Selects from (queries) the datastore for rows matching the specified query conditions.
 void setConnectionInfo(SQLConnectionInfo connectionInfo)
           
 void setDataSource(DataSource dataSource)
           
protected  void setObject(PreparedStatement ps, int pos, Object value, String type)
          Handles default conversions that should work with most JDBC drivers.
 void update(Row row)
          Updates a row against the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionInfo

protected SQLConnectionInfo connectionInfo

logger

protected Logger logger

dataSource

protected DataSource dataSource

currentConnection

protected Connection currentConnection

readOnly

protected boolean readOnly
Constructor Detail

BaseSQLDriver

public BaseSQLDriver()
Method Detail

setConnectionInfo

public void setConnectionInfo(SQLConnectionInfo connectionInfo)

setDataSource

public void setDataSource(DataSource dataSource)

inTransaction

protected boolean inTransaction()

begin

public void begin(boolean readOnly)
           throws DriverException
Specified by:
begin in interface DatastoreDriver
DriverException

commit

public void commit()
            throws DriverException
Specified by:
commit in interface DatastoreDriver
DriverException

rollback

public void rollback()
              throws DriverException
Specified by:
rollback in interface DatastoreDriver
DriverException

createPreparedStatements

protected BaseSQLDriver.PreparedStatements createPreparedStatements(Table table)
Subclasses should override this if they need to provide custom SQL generation for the prepared statements.


getStatements

protected BaseSQLDriver.PreparedStatements getStatements(Table table)

create

public void create(Row row)
            throws DriverException
Description copied from interface: DatastoreDriver
Creates (inserts) a new row in the datastore. If the table is configured for autoincrement or sequence ID generation, the object ID is generated using that method before the row is inserted.

Specified by:
create in interface DatastoreDriver
DriverException

update

public void update(Row row)
            throws DriverException
Updates a row against the database. Uses the dirty bit settings on Row to determine which fields to update.

Specified by:
update in interface DatastoreDriver
DriverException

delete

public void delete(Row row)
            throws DriverException
Description copied from interface: DatastoreDriver
Permanently deletes a single row from the datastore.

Specified by:
delete in interface DatastoreDriver
DriverException

count

public int count(Selector selector)
          throws DriverException
Description copied from interface: DatastoreDriver
Returns the size of the results that would be returned by the query. A naive implementation would be to return select(selector, ...).size(). However, this allows datastores that provide a native count feature to use far less network and memory resources.

Specified by:
count in interface DatastoreDriver
DriverException

select

public Collection select(Selector selector,
                         Set extraRows)
                  throws DriverException
Description copied from interface: DatastoreDriver
Selects from (queries) the datastore for rows matching the specified query conditions.

Specified by:
select in interface DatastoreDriver
Parameters:
selector - the root of the parse tree representing the query
extraRows - a non-null set to which additional objects read from the datastore can be added, as advised by fetch group information and optimization choices.
Returns:
a collection of Row objects matching the selection criteria.
DriverException

setObject

protected void setObject(PreparedStatement ps,
                         int pos,
                         Object value,
                         String type)
                  throws SQLException
Handles default conversions that should work with most JDBC drivers. Instances of java.util.Date are converted to java.sql.Timestamp; values for SQL "CHAR" columns are converted into a character stream.

SQLException


$Header: /cvsroot/xorm/xorm/docs/api/org/xorm/datastore/sql/BaseSQLDriver.html,v 1.9 2004/05/30 08:55:06 wbiggs Exp $