org.brains2b.sql.oracle
Class OracleCondition

java.lang.Object
  |
  +--org.brains2b.data.Condition
        |
        +--org.brains2b.sql.oracle.OracleCondition

public class OracleCondition
extends Condition

Oracle Condition is a specific implementation of Condition for Oracle databases.

Version:
0.23.1 [14-12-2003]
Author:
dennis@brains2b.nl
See Also:
org.brainsb2.data.Condition

Field Summary
 
Fields inherited from class org.brains2b.data.Condition
mCond, mOrderBy
 
Constructor Summary
OracleCondition()
          Default Constructor
OracleCondition(java.lang.String orderBy)
          Constructor for OracleCondition
OracleCondition(java.lang.String field, java.lang.Object value)
          Constructor for OracleCondition
OracleCondition(java.lang.String field, java.lang.Object value, java.lang.String orderBy)
          Constructor for OracleCondition
 
Method Summary
 void addCondition(java.lang.String field, java.util.Date value)
          Implementation of addCondition which converts normal java.util.Date to java.sql.Timestamp which is appropriate for Oracle
 void addCondition(java.lang.String field, java.lang.Object value)
          Implementation of addCondition which checks for null values and makes them absolute so the condition will have a condition FIELD IS NULL in the query.
 void addOrderBy(java.lang.String field, boolean descending)
          adds an Order By statement with the option to sort it descending
 void addParameter(int idx, int i)
          adds a integer value for the given placeholder position in the prepared statement.
 void addParameter(int idx, java.lang.Object o)
          adds a value for the given placeholder position in the prepared statement.
 java.lang.Object getCondition()
          abstract function left to specific datasource implementation to actually use condition and order by in a way the implementation does understand
 java.lang.String getPreparedQuery()
          get the SQL WHERE clause
 java.sql.PreparedStatement getPreparedStatement(java.sql.Connection con, java.lang.String select)
          returns a prepared statement build from the prepared query set, the parameters added, the conditions set and the order by supplied.
 void setPreparedQuery(java.lang.String preparedQuery)
          set the SQL WHERE clause for this condition.
 
Methods inherited from class org.brains2b.data.Condition
addCondition, addOrderBy, clearOrderBy, equals, getConditions, getOrderBy, removeCondition
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleCondition

public OracleCondition()
Default Constructor

See Also:
Condition.Condition()

OracleCondition

public OracleCondition(java.lang.String orderBy)
Constructor for OracleCondition

See Also:
Condition.Condition(String)

OracleCondition

public OracleCondition(java.lang.String field,
                       java.lang.Object value)
Constructor for OracleCondition

See Also:
Condition.Condition(String, Object)

OracleCondition

public OracleCondition(java.lang.String field,
                       java.lang.Object value,
                       java.lang.String orderBy)
Constructor for OracleCondition

See Also:
Condition.Condition(String, Object, String)
Method Detail

getCondition

public java.lang.Object getCondition()
Description copied from class: Condition
abstract function left to specific datasource implementation to actually use condition and order by in a way the implementation does understand

Specified by:
getCondition in class Condition
Returns:
Object, most general implementation.
See Also:
Condition.getCondition()

getPreparedStatement

public java.sql.PreparedStatement getPreparedStatement(java.sql.Connection con,
                                                       java.lang.String select)
                                                throws java.sql.SQLException
returns a prepared statement build from the prepared query set, the parameters added, the conditions set and the order by supplied.

If a prepared query has placeholders, the addParameters must be called for every placeholder supplied.

Parameters:
con - Connection, the connection for which to prepare the query
Returns:
PreparedStatement, the PreparedStatement created for execution
Throws:
SQLException, - throws the Exception if generated by the prepareStatement command in java.sql.Connection()
java.sql.SQLException
See Also:
java.sql.Connection(), PreparedStatement

setPreparedQuery

public void setPreparedQuery(java.lang.String preparedQuery)
set the SQL WHERE clause for this condition. Could be used in conjunction with placeholder character ? to later set parameters to.

A prepared query is a query containing only the query for a table, with or without the "WHERE" keyword.

Parameters:
preparedQuery - The preparedQuery to set

getPreparedQuery

public java.lang.String getPreparedQuery()
get the SQL WHERE clause

Returns:
String, the query String generated from supplied condtions and prepared queries.

addParameter

public void addParameter(int idx,
                         java.lang.Object o)
adds a value for the given placeholder position in the prepared statement.

Parameters:
idx - int, the placeholder position
o - Object, the value to set in the prepared statement.

addParameter

public void addParameter(int idx,
                         int i)
adds a integer value for the given placeholder position in the prepared statement.

Parameters:
idx - int, the placeholder position
i - int, The value to set in the prepared statement

addCondition

public void addCondition(java.lang.String field,
                         java.lang.Object value)
Implementation of addCondition which checks for null values and makes them absolute so the condition will have a condition FIELD IS NULL in the query.

The normal addCondition(String, Object) does not do this by default and implementations can differ from data storage to data storage

Overrides:
addCondition in class Condition
Parameters:
field - String, the identifier
value - Object, the value
See Also:
Condition.addCondition(String, Object)

addCondition

public void addCondition(java.lang.String field,
                         java.util.Date value)
Implementation of addCondition which converts normal java.util.Date to java.sql.Timestamp which is appropriate for Oracle

This method checks for null values and makes them absolute so the condition will have a condition FIELD IS NULL in the query.

This needs to be done for all output, database types differently

See Also:
Condition.addCondition(String, Object)

addOrderBy

public void addOrderBy(java.lang.String field,
                       boolean descending)
adds an Order By statement with the option to sort it descending

Parameters:
field - String, the field name as it occurs in the table
Since:
DataC 0.23