com.googlecode.jpattern.orm.query.sql
Class SqlQuery

java.lang.Object
  extended by com.googlecode.jpattern.orm.query.AQuery
      extended by com.googlecode.jpattern.orm.query.sql.SqlQuery
All Implemented Interfaces:
ICustomQuery, IQuery, IRenderableSqlObject, ISqlQuery

public class SqlQuery
extends AQuery
implements ISqlQuery

Author:
Francesco Cina 09/lug/2011

Constructor Summary
SqlQuery(ISessionSqlPerformer session, String sql, Object[] args)
           
 
Method Summary
 void appendValues(List<Object> values)
          Append to the list all the values of the expression's elements
<T> T
find(IResultSetReader<T> rse)
          Execute the query reading the ResultSet with a IResultSetReader.
 BigDecimal findBigDecimal()
          Execute the query and read the result as a BigDecimal value
 boolean findBoolean()
          Execute the query and read the result as a boolean value
 double findDouble()
          Execute the query and read the result as a double value
 float findFloat()
          Execute the query and read the result as a float value
 int findInt()
          Execute the query and read the result as an int value
 List<Object[]> findList()
          Execute the query and read the result creating a List of all the ordered arrays with the extracted column values for every row.
 long findLong()
          Execute the query and read the result as an long value
 String findString()
          Execute the wuery and read the result as a String value
 Object[] findUnique()
          Execute the query and read the result creating an ordered array with the extracted column values or null (if no matching bean is found).
 int getMaxRows()
          Return the max rows for this query.
 int getQueryTimeout()
          Return the query timeout for the query.
 String renderSql()
          Return the sql query generated by this IQuery Object
 void renderSql(StringBuilder StringBuilder)
          Append to the string buffer the sql query generated by this IQuery Object
 ISqlQuery setMaxRows(int maxRows)
          Set the maximum number of rows to return in the query.
 ISqlQuery setQueryTimeout(int queryTimeout)
          Set the query timeout for the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlQuery

public SqlQuery(ISessionSqlPerformer session,
                String sql,
                Object[] args)
Method Detail

getMaxRows

public final int getMaxRows()
                     throws OrmException
Description copied from interface: IQuery
Return the max rows for this query.

Specified by:
getMaxRows in interface IQuery
Returns:
Throws:
OrmException

setQueryTimeout

public final ISqlQuery setQueryTimeout(int queryTimeout)
Description copied from interface: ISqlQuery
Set the query timeout for the query.

Specified by:
setQueryTimeout in interface IQuery
Specified by:
setQueryTimeout in interface ISqlQuery

getQueryTimeout

public final int getQueryTimeout()
Description copied from interface: IQuery
Return the query timeout for the query.

Specified by:
getQueryTimeout in interface IQuery

setMaxRows

public final ISqlQuery setMaxRows(int maxRows)
                           throws OrmException
Description copied from interface: ISqlQuery
Set the maximum number of rows to return in the query.

Specified by:
setMaxRows in interface IQuery
Specified by:
setMaxRows in interface ISqlQuery
Returns:
Throws:
OrmException

find

public <T> T find(IResultSetReader<T> rse)
       throws OrmException
Description copied from interface: ICustomQuery
Execute the query reading the ResultSet with a IResultSetReader.

Specified by:
find in interface ICustomQuery
Parameters:
rse - object that will extract all rows of results
Returns:
an arbitrary result object, as returned by the IResultSetExtractor
Throws:
OrmException

findList

public List<Object[]> findList()
                        throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result creating a List of all the ordered arrays with the extracted column values for every row.

Specified by:
findList in interface ICustomQuery
Returns:
Throws:
OrmException

findUnique

public Object[] findUnique()
                    throws OrmNotUniqueResultException
Description copied from interface: ICustomQuery
Execute the query and read the result creating an ordered array with the extracted column values or null (if no matching bean is found).

Specified by:
findUnique in interface ICustomQuery
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query

findInt

public int findInt()
            throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as an int value

Specified by:
findInt in interface ICustomQuery
Returns:
Throws:
OrmException

findLong

public long findLong()
              throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as an long value

Specified by:
findLong in interface ICustomQuery
Returns:
Throws:
OrmException

findDouble

public double findDouble()
                  throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as a double value

Specified by:
findDouble in interface ICustomQuery
Returns:
Throws:
OrmException

findFloat

public float findFloat()
                throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as a float value

Specified by:
findFloat in interface ICustomQuery
Returns:
Throws:
OrmException

findString

public String findString()
                  throws OrmException
Description copied from interface: ICustomQuery
Execute the wuery and read the result as a String value

Specified by:
findString in interface ICustomQuery
Returns:
Throws:
OrmException

findBoolean

public boolean findBoolean()
                    throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as a boolean value

Specified by:
findBoolean in interface ICustomQuery
Returns:
Throws:
OrmException

findBigDecimal

public BigDecimal findBigDecimal()
                          throws OrmException
Description copied from interface: ICustomQuery
Execute the query and read the result as a BigDecimal value

Specified by:
findBigDecimal in interface ICustomQuery
Returns:
Throws:
OrmException

appendValues

public void appendValues(List<Object> values)
Description copied from interface: IQuery
Append to the list all the values of the expression's elements

Specified by:
appendValues in interface IQuery

renderSql

public String renderSql()
Description copied from interface: IRenderableSqlObject
Return the sql query generated by this IQuery Object

Specified by:
renderSql in interface IRenderableSqlObject
Returns:

renderSql

public void renderSql(StringBuilder StringBuilder)
Description copied from interface: IRenderableSqlObject
Append to the string buffer the sql query generated by this IQuery Object

Specified by:
renderSql in interface IRenderableSqlObject


Copyright © 2011. All Rights Reserved.