com.onewebsql.query.adapter
Class OracleDBAdapter

java.lang.Object
  extended by com.onewebsql.query.adapter.BaseDBAdapter
      extended by com.onewebsql.query.adapter.OracleDBAdapter
All Implemented Interfaces:
DBAdapter

public class OracleDBAdapter
extends BaseDBAdapter

Implementation of DBAdapter interface for the Oracle database.


Field Summary
 
Fields inherited from class com.onewebsql.query.adapter.BaseDBAdapter
DEFAULT_VALUE_LIST_PARAMETER_HANDLER, LOB_BURST_SIZE, NEXT_VALUE_FOR, SEQUENCE_ROW_HANDLER
 
Constructor Summary
OracleDBAdapter()
          Constructor.
 
Method Summary
 void buildQuery(SelectQuery query, String schemaName, StringBuilder sb, List<Value> objs)
          Builds a SELECT query in a way specific for Oracle.
 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.
 
Methods inherited from class com.onewebsql.query.adapter.BaseDBAdapter
buildIdWhere, getBlob, getClob, getValueListParameterHandler, join, setBlob, setClob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDBAdapter

public OracleDBAdapter()
Constructor.

Method Detail

buildQuery

public void buildQuery(SelectQuery query,
                       String schemaName,
                       StringBuilder sb,
                       List<Value> objs)
Builds a SELECT query in a way specific for Oracle. It handles SELECT limits in a different way. If an upper limit is present (LIMIT) the following query is built:
 SELECT ORIGINAL_QUERY.<first column in original query>, ORIGINAL_QUERY.<second column in original query>, ...
 FROM 
 (
        SELECT <first column in original query>, <second column in original query>, ..., ROW_NUMBER() OVER(< ORDER BY clause of the original query>) ROWNUMBER
        // rest of the original query with the ORDER BY clause removed
 ) 
 ORIGINAL_QUERY 
 WHERE ROWNUMBER <= <LIMIT>
 
If the original query has no ORDER BY clause then the argument of the function ROW_NUMBER OVER() is the virtual column ROWNUM.
If both an upper and a lower limit are present (OFFSET), the following query is built:
 SELECT ORIGINAL_QUERY.<first column in original query>, ORIGINAL_QUERY.<second column in original query>, ...
 FROM 
 (
        SELECT <first column in original query>, <second column in original query>, ..., ROW_NUMBER() OVER(<ORDER BY clause of the original query>) ROWNUMBER
        // rest of the original query with the ORDER BY clause removed
 ) 
 ORIGINAL_QUERY 
 WHERE ROWNUMBER > <OFFSET> AND ROWNUMBER <= <LIMIT + OFFSET>
 

Specified by:
buildQuery in interface DBAdapter
Overrides:
buildQuery in class BaseDBAdapter
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)
Returns the next value from the sequence with the specified name and the specified schema name, from the specified data source. The sequence should be created by the SQL script which creates the database structure.

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


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