org.pojava.persistence.query
Class SqlQuery

java.lang.Object
  extended by org.pojava.persistence.query.AbstractQuery
      extended by org.pojava.persistence.query.SqlQuery
All Implemented Interfaces:
PreparedSqlProvider

public class SqlQuery
extends AbstractQuery
implements PreparedSqlProvider

A SqlQuery object is used to build query criteria with a contract to produce a PreparedSql object matching those criteria.

Author:
John Pile

Field Summary
protected  org.pojava.lang.BoundString sql
          SQL fragment (typically everything after the SELECT clause and before the ORDER BY clause) Note that this class will likely grow to support more than just SQL.
protected  String sqlOrderBy
          Order By clause of the SQL statement.
 
Constructor Summary
SqlQuery()
          Default constructor.
SqlQuery(org.pojava.lang.BoundString boundSql)
          Construct a new Sql query from a BoundString.
SqlQuery(org.pojava.lang.BoundString boundSql, int maxRows)
          Construct a new SQL query from a BoundString specifing a row limit.
 
Method Summary
protected  void addBinding(Class<Object> type, Object value)
           
protected  void appendSql(org.pojava.lang.BoundString newSql)
          Append some SQL
protected  void appendSql(String newSql)
          Append some SQL
 PreparedSql generatePreparedSql(org.pojava.lang.BoundString prefix)
          Generate Prepared SQL ready for execution.
 PreparedSql generatePreparedSql(String prefix)
          Generate a PreparedSql statement from your prefix (such as "SELECT * from table") and this query.
protected  void insertSql(org.pojava.lang.BoundString newSql)
          Insert some SQL
protected  void insertSql(String newSql)
          Insert some SQL
protected  void whereAnd(org.pojava.lang.BoundString predicate)
          Append some SQL with a "WHERE" or "AND" prefix.
protected  void whereAnd(String newSql)
          Append some SQL with a "WHERE" or "AND" prefix.
 
Methods inherited from class org.pojava.persistence.query.AbstractQuery
getMaxRows, setMaxRows
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sql

protected final org.pojava.lang.BoundString sql
SQL fragment (typically everything after the SELECT clause and before the ORDER BY clause) Note that this class will likely grow to support more than just SQL.


sqlOrderBy

protected String sqlOrderBy
Order By clause of the SQL statement.

Constructor Detail

SqlQuery

public SqlQuery()
Default constructor.


SqlQuery

public SqlQuery(org.pojava.lang.BoundString boundSql)
Construct a new Sql query from a BoundString.

Parameters:
boundSql -

SqlQuery

public SqlQuery(org.pojava.lang.BoundString boundSql,
                int maxRows)
Construct a new SQL query from a BoundString specifing a row limit.

Parameters:
boundSql -
maxRows -
Method Detail

appendSql

protected void appendSql(org.pojava.lang.BoundString newSql)
Append some SQL

Parameters:
newSql -

appendSql

protected void appendSql(String newSql)
Append some SQL

Parameters:
newSql -

addBinding

protected void addBinding(Class<Object> type,
                          Object value)

insertSql

protected void insertSql(org.pojava.lang.BoundString newSql)
Insert some SQL

Parameters:
newSql -

insertSql

protected void insertSql(String newSql)
Insert some SQL

Parameters:
newSql -

whereAnd

protected void whereAnd(String newSql)
Append some SQL with a "WHERE" or "AND" prefix.

Parameters:
newSql -

whereAnd

protected void whereAnd(org.pojava.lang.BoundString predicate)
Append some SQL with a "WHERE" or "AND" prefix.

Parameters:
predicate - A freeform expression evaluating to true or false

generatePreparedSql

public PreparedSql generatePreparedSql(String prefix)
Generate a PreparedSql statement from your prefix (such as "SELECT * from table") and this query.

Specified by:
generatePreparedSql in interface PreparedSqlProvider
Parameters:
prefix -
Returns:
SQL statement ready for execution

generatePreparedSql

public PreparedSql generatePreparedSql(org.pojava.lang.BoundString prefix)
Generate Prepared SQL ready for execution.

Specified by:
generatePreparedSql in interface PreparedSqlProvider
Returns:
a a SQL statement ready for processing.


Copyright © 2011. All Rights Reserved.