com.onewebsql.query.adapter
Class BaseDBAdapter

java.lang.Object
  extended by com.onewebsql.query.adapter.BaseDBAdapter
All Implemented Interfaces:
DBAdapter
Direct Known Subclasses:
DB2DBAdapter, HSQLDB2Adapter, MSSQLDBAdapter, MySQLDBAdapter, OracleDBAdapter, PostgresDBAdapter

public abstract class BaseDBAdapter
extends Object
implements DBAdapter

Base class for the implementations of DBAdapter interface.


Field Summary
static ParameterHandler<List<Value>> DEFAULT_VALUE_LIST_PARAMETER_HANDLER
          Standard parameter handler which binds value to SQL statement parameters.
static int LOB_BURST_SIZE
          Defines how large the first package of data (in bytes or in characters) written to LOB objects can be
static String NEXT_VALUE_FOR
          SQL prefix to get the next value of the sequence (compliant with SQL3).
static RowHandler<Long> SEQUENCE_ROW_HANDLER
          Row handler to retrieve the value of the sequence.
 
Constructor Summary
BaseDBAdapter()
           
 
Method Summary
 LExp buildIdWhere(Column column, Object id)
          Builds a logical expression LExp which is used to retrieve a row based on the value of the key.
 void buildQuery(SelectQuery query, String schemaName, StringBuilder sb, List<Value> objs)
          Builds a SELECT query in a way specific for the database.
 boolean getBlob(DataSource ds, String schemaName, Column column, Object id, OutputStream is, long length)
          Retrieves the value of Blob column and writes its contents to the specified stream.
 boolean getClob(DataSource ds, String schemaName, Column column, Object id, Writer writer, long length)
          Retrieves the value of Clob column and writes its contents to the specified Writer.
 Long getNextId(String sequenceName, String schemaName, DataSource ds)
          Returns the next value from the sequence with the specified name and the specified schema name, from the specified data source.
 ParameterHandler<List<Value>> getValueListParameterHandler()
          Returns an object binding the value lists built by OneWebSQL to SQL query parameters in a way specific for the database.
 boolean join(Join join, String schemaName, StringBuilder sb, List<Value> objs)
          Does nothing and returns false.
 void setBlob(DataSource ds, String schemaName, Column column, Object id, InputStream is, long length)
          Reads from the specified stream and writes its contents to the Blob column.
 void setClob(DataSource ds, String schemaName, Column column, Object id, Reader reader, long length)
          Reads from the specified Reader and writes its contents to the Clob column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOB_BURST_SIZE

public static final int LOB_BURST_SIZE
Defines how large the first package of data (in bytes or in characters) written to LOB objects can be

See Also:
SetBlobOp, SetClobOp, Constant Field Values

NEXT_VALUE_FOR

public static final String NEXT_VALUE_FOR
SQL prefix to get the next value of the sequence (compliant with SQL3).

See Also:
Constant Field Values

SEQUENCE_ROW_HANDLER

public static final RowHandler<Long> SEQUENCE_ROW_HANDLER
Row handler to retrieve the value of the sequence.


DEFAULT_VALUE_LIST_PARAMETER_HANDLER

public static final ParameterHandler<List<Value>> DEFAULT_VALUE_LIST_PARAMETER_HANDLER
Standard parameter handler which binds value to SQL statement parameters.

Constructor Detail

BaseDBAdapter

public BaseDBAdapter()
Method Detail

join

public boolean join(Join join,
                    String schemaName,
                    StringBuilder sb,
                    List<Value> objs)
Does nothing and returns false.

Specified by:
join in interface DBAdapter
Parameters:
join - join query
schemaName - schema name used to build the query
sb - StringBuilder where we build the query
objs - an accumulator list to which join parameters are added
Returns:
false

buildQuery

public void buildQuery(SelectQuery query,
                       String schemaName,
                       StringBuilder sb,
                       List<Value> objs)
Description copied from interface: DBAdapter
Builds a SELECT query in a way specific for the database.

Specified by:
buildQuery in interface DBAdapter
Parameters:
query - SELECT query
schemaName - schema name used to build the query
sb - StringBuilder where we build the query
objs - an accumulator list to which join parameters are added

getNextId

public Long getNextId(String sequenceName,
                      String schemaName,
                      DataSource ds)
Description copied from interface: DBAdapter
Returns the next value from the sequence with the specified name and the specified schema name, from the specified data source.

Specified by:
getNextId in interface DBAdapter
Parameters:
sequenceName - sequence name
schemaName - name of the schema
ds - data source
Returns:
next value of the sequence

setBlob

public void setBlob(DataSource ds,
                    String schemaName,
                    Column column,
                    Object id,
                    InputStream is,
                    long length)
Description copied from interface: DBAdapter
Reads from the specified stream and writes its contents to the Blob column. The specified row must exist in the database. The row identifier might be

Specified by:
setBlob in interface DBAdapter
Parameters:
ds - data source
schemaName - name of the table's schema
column - column to which we are writing
id - row id
is - InputStream containing data to write or null if the column is to be set to NULL
length - the number of bytes to write or -1 if the whole stream content is to be written

getBlob

public boolean getBlob(DataSource ds,
                       String schemaName,
                       Column column,
                       Object id,
                       OutputStream is,
                       long length)
Description copied from interface: DBAdapter
Retrieves the value of Blob column and writes its contents to the specified stream. The row must exist in the database. The row identifier might be:

Specified by:
getBlob in interface DBAdapter
Parameters:
ds - data source
schemaName - name of the table's schema
column - column we are reading
id - row id
is - OutputStream to which the column contents is to be written
length - the maximal number of bytes to write or -1 if the whole column contents is to be written
Returns:
true if the column value was retrieved false if the column value was NULL

setClob

public void setClob(DataSource ds,
                    String schemaName,
                    Column column,
                    Object id,
                    Reader reader,
                    long length)
Description copied from interface: DBAdapter
Reads from the specified Reader and writes its contents to the Clob column. The specified row must exist in the database. The row identifier might be

Specified by:
setClob in interface DBAdapter
Parameters:
ds - data source
schemaName - name of the table's schema
column - column to which we are writing
id - row id
reader - Reader containing data to write or null if the column is to be set to NULL
length - the number of bytes to write or -1 if the whole stream content is to be written

getClob

public boolean getClob(DataSource ds,
                       String schemaName,
                       Column column,
                       Object id,
                       Writer writer,
                       long length)
Description copied from interface: DBAdapter
Retrieves the value of Clob column and writes its contents to the specified Writer. The row must exist in the database. The row identifier might be:

Specified by:
getClob in interface DBAdapter
Parameters:
ds - data source
schemaName - name of the table's schema
column - column we are reading
id - row id
writer - writer to which the column contents is to be written
length - the maximal number of bytes to write or -1 if the whole column contents is to be written
Returns:
true if the column value was retrieved false if the column value was NULL

getValueListParameterHandler

public ParameterHandler<List<Value>> getValueListParameterHandler()
Description copied from interface: DBAdapter
Returns an object binding the value lists built by OneWebSQL to SQL query parameters in a way specific for the database.

Specified by:
getValueListParameterHandler in interface DBAdapter
Returns:
an object binding value lists to SQL query parameters
See Also:
SelectQuery.build(StringBuilder, String, List, DBAdapter), InsertQuery.build(StringBuilder, String, List, DBAdapter), DeleteQuery.build(StringBuilder, String, List, DBAdapter)

buildIdWhere

public LExp buildIdWhere(Column column,
                         Object id)
Builds a logical expression LExp which is used to retrieve a row based on the value of the key.

Parameters:
column - column of the table
id - value of the key. If it is a list (List) or an array of object, the elements of id are values for the consecutive columns of the key. Otherwise, the object is treated as a value of the key.
Returns:
logical expression LExp which is used to retrieve a row based on the value of the key


Copyright © 2011-2013 e-point SA. All Rights Reserved.