|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.data.Condition
org.brains2b.data.sql.SqlCondition
public class SqlCondition
SqlCondition is a specific implementation of Condition for SQL databases.
Condition
Field Summary |
---|
Fields inherited from class org.brains2b.data.Condition |
---|
m_cond, m_orderBy |
Constructor Summary | |
---|---|
SqlCondition()
Default Constructor |
|
SqlCondition(java.lang.String orderBy)
Constructor for SqlCondition |
|
SqlCondition(java.lang.String field,
java.lang.Object value)
Constructor for SqlCondition |
|
SqlCondition(java.lang.String field,
java.lang.Object value,
java.lang.String orderBy)
Constructor for SqlCondition |
Method Summary | |
---|---|
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, 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 |
---|
public SqlCondition()
public SqlCondition(java.lang.String orderBy)
public SqlCondition(java.lang.String field, java.lang.Object value)
public SqlCondition(java.lang.String field, java.lang.Object value, java.lang.String orderBy)
Method Detail |
---|
public java.lang.Object getCondition()
Condition
getCondition
in class Condition
public java.sql.PreparedStatement getPreparedStatement(java.sql.Connection con, java.lang.String select) throws java.sql.SQLException
If a prepared query has placeholders, the addParameters must be called for every placeholder supplied.
con
- Connection, the connection for which to prepare the queryselect
- String, the select containing the fields to retrieve and the table
This should be a valid ANSI-SQL `SELECT` statement without any conditions.
SQLException,
- throws the Exception if generated by the prepareStatement
command in java.sql.Connection()
java.sql.SQLException
Connection
,
PreparedStatement
public void setPreparedQuery(java.lang.String preparedQuery)
?
to later set parameters to.
A prepared query is a query containing only the query for a table, with or without the "WHERE" keyword.
preparedQuery
- The preparedQuery to setpublic java.lang.String getPreparedQuery()
public void addParameter(int idx, java.lang.Object o)
idx
- int, the placeholder positiono
- Object, the value to set in the prepared statement.public void addParameter(int idx, int i)
idx
- int, the placeholder positioni
- int, The value to set in the prepared statementpublic void addCondition(java.lang.String field, java.lang.Object value)
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
converts java.util.Date
to java.sql.Timestamp
which is
appropriate for Oracle
addCondition
in class Condition
field
- String, the identifiervalue
- Object, the valueaddCondition(String, Object)
public void addOrderBy(java.lang.String field, boolean descending)
field
- String, the field name as it occurs in the tabledescending
- boolean, true if you want to sort descending.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |