com.googlecode.jpattern.orm.query
Class OrmQuery<T>

java.lang.Object
  extended by com.googlecode.jpattern.orm.query.AQuery
      extended by com.googlecode.jpattern.orm.query.ABaseOrmQuery
          extended by com.googlecode.jpattern.orm.query.OrmQuery<T>
All Implemented Interfaces:
IBaseOrmQuery, INameSolverConsumer, IOrmQuery<T>, IQuery, IRenderableSqlObject

public class OrmQuery<T>
extends ABaseOrmQuery
implements IOrmQuery<T>, INameSolverConsumer

Author:
Francesco Cina 20/giu/2011

Constructor Summary
OrmQuery(IOrmClassToolMap ormClassToolMap, ISessionSqlPerformer session, Class<T> clazz, Class<?>... joinClasses)
           
 
Method Summary
 void find(IOrmSerialResultReader<T> srr)
          Execute the query and for every object created call the IOrmSerialResultReader.
 List<T> findList()
          Execute the query returning the list of objects.
 long findRowCount()
          Return the count of entities this query should return.
 T findUnique()
          Execute the query returning either a single bean or null (if no matching bean is found).
 String getGeneratedRowCountSql()
          Return the sql that was generated for to return the row count of the execution of this query.
 int getMaxRows()
          Return the max rows for this query.
 int getQueryTimeout()
          Return the query timeout for the query.
 boolean isDistinct()
          return if use Distinct in the select clause
protected  void renderFrom(StringBuilder StringBuilder)
           
protected  void renderOrderBy(StringBuilder StringBuilder)
           
protected  void renderSelect(StringBuilder StringBuilder)
           
protected  void renderWhere(StringBuilder StringBuilder)
           
 IOrmQuery<T> setDistinct()
          use Distinct in the select clause
 IOrmQuery<T> setMaxRows(int maxRows)
          Set the maximum number of rows to return in the query.
 void setNameSolver(INameSolver nameSolver)
           
 IOrmQuery<T> setQueryTimeout(int queryTimeout)
          Set the query timeout for the query.
 
Methods inherited from class com.googlecode.jpattern.orm.query.ABaseOrmQuery
appendValues, join, orderBy, renderSql, renderSql, setJoin, setOrderBy, setWhere, where
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.googlecode.jpattern.orm.query.IBaseOrmQuery
join, orderBy, where
 
Methods inherited from interface com.googlecode.jpattern.orm.query.IQuery
appendValues
 
Methods inherited from interface com.googlecode.jpattern.orm.query.IRenderableSqlObject
renderSql, renderSql
 

Constructor Detail

OrmQuery

public OrmQuery(IOrmClassToolMap ormClassToolMap,
                ISessionSqlPerformer session,
                Class<T> clazz,
                Class<?>... joinClasses)
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 IOrmQuery<T> setQueryTimeout(int queryTimeout)
Description copied from interface: IOrmQuery
Set the query timeout for the query.

Specified by:
setQueryTimeout in interface IOrmQuery<T>
Specified by:
setQueryTimeout in interface IQuery

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 IOrmQuery<T> setMaxRows(int maxRows)
                              throws OrmException
Description copied from interface: IOrmQuery
Set the maximum number of rows to return in the query.

Specified by:
setMaxRows in interface IOrmQuery<T>
Specified by:
setMaxRows in interface IQuery
Returns:
Throws:
OrmException

setNameSolver

public void setNameSolver(INameSolver nameSolver)
Specified by:
setNameSolver in interface INameSolverConsumer

findList

public List<T> findList()
Description copied from interface: IOrmQuery
Execute the query returning the list of objects.

Specified by:
findList in interface IOrmQuery<T>
Returns:

find

public void find(IOrmSerialResultReader<T> srr)
          throws OrmException
Description copied from interface: IOrmQuery
Execute the query and for every object created call the IOrmSerialResultReader. The objects are created one after the other to avoid the use of too much memory.

Specified by:
find in interface IOrmQuery<T>
Throws:
OrmException

findRowCount

public long findRowCount()
Description copied from interface: IOrmQuery
Return the count of entities this query should return.

Specified by:
findRowCount in interface IOrmQuery<T>
Returns:

findUnique

public T findUnique()
             throws OrmNotUniqueResultException
Description copied from interface: IOrmQuery
Execute the query returning either a single bean or null (if no matching bean is found).

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

getGeneratedRowCountSql

public String getGeneratedRowCountSql()
Description copied from interface: IOrmQuery
Return the sql that was generated for to return the row count of the execution of this query.

Specified by:
getGeneratedRowCountSql in interface IOrmQuery<T>
Returns:

setDistinct

public IOrmQuery<T> setDistinct()
Description copied from interface: IOrmQuery
use Distinct in the select clause

Specified by:
setDistinct in interface IOrmQuery<T>
Returns:

renderSelect

protected void renderSelect(StringBuilder StringBuilder)
Specified by:
renderSelect in class ABaseOrmQuery

renderFrom

protected void renderFrom(StringBuilder StringBuilder)
Specified by:
renderFrom in class ABaseOrmQuery

renderWhere

protected void renderWhere(StringBuilder StringBuilder)
Specified by:
renderWhere in class ABaseOrmQuery

renderOrderBy

protected void renderOrderBy(StringBuilder StringBuilder)
Specified by:
renderOrderBy in class ABaseOrmQuery

isDistinct

public boolean isDistinct()
                   throws OrmException
Description copied from interface: IOrmQuery
return if use Distinct in the select clause

Specified by:
isDistinct in interface IOrmQuery<T>
Returns:
Throws:
OrmException


Copyright © 2011. All Rights Reserved.