com.jpattern.orm.query.find
Class FindQueryOrm<BEAN>

java.lang.Object
  extended by com.jpattern.orm.query.SmartRenderableSqlQuery
      extended by com.jpattern.orm.query.find.FindQueryOrm<BEAN>
All Implemented Interfaces:
BaseFindQuery, From<FindQuery<BEAN>>, SqlClause<FindQuery<BEAN>>, FindFrom<BEAN>, FindQuery<BEAN>, FindQueryCommon<BEAN>, NameSolverConsumer, QueryRoot, RenderableSqlQuery

public class FindQueryOrm<BEAN>
extends SmartRenderableSqlQuery
implements FindQuery<BEAN>, NameSolverConsumer

Author:
Francesco Cina 20/giu/2011

Constructor Summary
FindQueryOrm(IOrmClassToolMap ormClassToolMap, SessionSqlPerformer session, Class<BEAN> clazz, Integer nameSolverClassId, TypeFactory typeFactory)
           
 
Method Summary
 void appendValues(List<Object> values)
          Append to the list all the values of the expression's elements
 void doRender(StringBuilder stringBuilder)
           
 BEAN find()
          Execute the query returning either a single bean, if the ResultSet contains at least one row, or null, if no matching beans are found).
 void find(OrmRowMapper<BEAN> srr)
          Execute the query and for every object created call the IOrmSerialResultReader.
 List<BEAN> findList()
          Execute the query returning the list of objects.
 int findRowCount()
          Return the count of entities this query should return.
 BEAN findUnique()
          Execute the query returning either a single bean or an Exception.
 FindQuery<BEAN> fullOuterJoin(Class<?> joinClass)
          Perform a natural full outer Join.
 FindQuery<BEAN> fullOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural full outer Join.
 FindQuery<BEAN> fullOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a full outer Join.
 FindQuery<BEAN> fullOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform full outer Join.
 String getGeneratedRowCountSql()
          Return the sql that was generated to return the row count of the execution of this query.
 LockMode getLockMode()
          Return the current lock mode
 int getMaxRows()
          Return the max rows for this query.
 int getQueryTimeout()
          Return the query timeout for the query.
 int getStatusVersion()
           
 FindQuery<BEAN> innerJoin(Class<?> joinClass)
          Perform a inner Join.
 FindQuery<BEAN> innerJoin(Class<?> joinClass, String joinClassAlias)
          Perform a inner Join.
 FindQuery<BEAN> innerJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a inner Join.
 FindQuery<BEAN> innerJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform a inner Join.
 boolean isDistinct()
          return if use Distinct in the select clause
 FindQuery<BEAN> join(Class<?> joinClass)
          Perform a simple (cross) Join.
 FindQuery<BEAN> join(Class<?> joinClass, String joinClassAlias)
          Perform a simple (cross) Join.
 FindQuery<BEAN> leftOuterJoin(Class<?> joinClass)
          Perform a natural left outer Join.
 FindQuery<BEAN> leftOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural left outer Join.
 FindQuery<BEAN> leftOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a left outer Join.
 FindQuery<BEAN> leftOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform left outer Join.
 FindQuery<BEAN> naturalJoin(Class<?> joinClass)
          Perform a natural Join.
 FindQuery<BEAN> naturalJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural Join.
 FindOrderBy<BEAN> orderBy()
          Set the order by clause.
 FindQuery<BEAN> rightOuterJoin(Class<?> joinClass)
          Perform a natural right outer Join.
 FindQuery<BEAN> rightOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural right outer Join.
 FindQuery<BEAN> rightOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a right outer Join.
 FindQuery<BEAN> rightOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform right outer Join.
 FindQuery<BEAN> setDistinct(boolean distinct)
          Whether to use Distinct in the select clause
 FindQuery<BEAN> setLockMode(LockMode lockMode)
           
 FindQuery<BEAN> setMaxRows(int maxRows)
          Set the maximum number of rows to return in the query.
 void setNameSolver(NameSolver nameSolver)
           
 FindQuery<BEAN> setQueryTimeout(int queryTimeout)
          Set the query timeout for the query.
 FindWhere<BEAN> where()
          Set the where clause.
 
Methods inherited from class com.jpattern.orm.query.SmartRenderableSqlQuery
isStatusChanged, renderSql, renderSql
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jpattern.orm.query.RenderableSqlQuery
renderSql, renderSql
 

Constructor Detail

FindQueryOrm

public FindQueryOrm(IOrmClassToolMap ormClassToolMap,
                    SessionSqlPerformer session,
                    Class<BEAN> clazz,
                    Integer nameSolverClassId,
                    TypeFactory typeFactory)
Method Detail

where

public final FindWhere<BEAN> where()
                            throws OrmException
Description copied from interface: FindQuery
Set the where clause.

Specified by:
where in interface FindQuery<BEAN>
Returns:
Throws:
OrmException

orderBy

public final FindOrderBy<BEAN> orderBy()
                                throws OrmException
Description copied from interface: FindQuery
Set the order by clause.

Specified by:
orderBy in interface FindQuery<BEAN>
Returns:
Throws:
OrmException

getMaxRows

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

Specified by:
getMaxRows in interface FindQueryCommon<BEAN>
Returns:
Throws:
OrmException

setQueryTimeout

public final FindQuery<BEAN> setQueryTimeout(int queryTimeout)
Description copied from interface: FindQueryCommon
Set the query timeout for the query.

Specified by:
setQueryTimeout in interface FindQueryCommon<BEAN>

getQueryTimeout

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

Specified by:
getQueryTimeout in interface FindQueryCommon<BEAN>

setMaxRows

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

Specified by:
setMaxRows in interface FindQueryCommon<BEAN>
Returns:
Throws:
OrmException

setNameSolver

public void setNameSolver(NameSolver nameSolver)
Specified by:
setNameSolver in interface NameSolverConsumer

find

public void find(OrmRowMapper<BEAN> srr)
          throws OrmException
Description copied from interface: FindQueryCommon
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 FindQueryCommon<BEAN>
Throws:
OrmException

findUnique

public BEAN findUnique()
                throws OrmNotUniqueResultException
Description copied from interface: FindQueryCommon
Execute the query returning either a single bean or an Exception.

Specified by:
findUnique in interface FindQueryCommon<BEAN>
Returns:
Throws:
OrmNotUniqueResultException - if zero or more than one row are returned from the query

findRowCount

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

Specified by:
findRowCount in interface FindQueryCommon<BEAN>
Returns:

setDistinct

public FindQuery<BEAN> setDistinct(boolean distinct)
Description copied from interface: FindQueryCommon
Whether to use Distinct in the select clause

Specified by:
setDistinct in interface FindQueryCommon<BEAN>
Returns:

isDistinct

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

Specified by:
isDistinct in interface FindQueryCommon<BEAN>
Returns:
Throws:
OrmException

getStatusVersion

public final int getStatusVersion()
Specified by:
getStatusVersion in class SmartRenderableSqlQuery

getGeneratedRowCountSql

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

Specified by:
getGeneratedRowCountSql in interface FindQueryCommon<BEAN>
Returns:

doRender

public final void doRender(StringBuilder stringBuilder)
Specified by:
doRender in class SmartRenderableSqlQuery

appendValues

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

Specified by:
appendValues in interface RenderableSqlQuery

setLockMode

public FindQuery<BEAN> setLockMode(LockMode lockMode)
Specified by:
setLockMode in interface FindQueryCommon<BEAN>
Returns:

getLockMode

public LockMode getLockMode()
Description copied from interface: FindQueryCommon
Return the current lock mode

Specified by:
getLockMode in interface FindQueryCommon<BEAN>
Returns:

join

public FindQuery<BEAN> join(Class<?> joinClass)
Description copied from interface: From
Perform a simple (cross) Join. This join returns the Cartesian product of rows from tables in the join. A cross join is the join commonly used when more tables are comma separated in a from clause. The name of the class will be used as alias.

Specified by:
join in interface From<FindQuery<BEAN>>
Returns:

join

public FindQuery<BEAN> join(Class<?> joinClass,
                            String joinClassAlias)
Description copied from interface: From
Perform a simple (cross) Join. This join returns the Cartesian product of rows from tables in the join. A cross join is the join commonly used when more tables are comma separated in a from clause.

Specified by:
join in interface From<FindQuery<BEAN>>
Returns:

naturalJoin

public FindQuery<BEAN> naturalJoin(Class<?> joinClass)
Description copied from interface: From
Perform a natural Join. The join predicate arises implicitly by comparing all columns in both tables that have the same column-names in the joined tables. The resulting joined table contains only one column for each pair of equally-named columns. The name of the class will be used as alias.

Specified by:
naturalJoin in interface From<FindQuery<BEAN>>
Returns:

naturalJoin

public FindQuery<BEAN> naturalJoin(Class<?> joinClass,
                                   String joinClassAlias)
Description copied from interface: From
Perform a natural Join. The join predicate arises implicitly by comparing all columns in both tables that have the same column-names in the joined tables. The resulting joined table contains only one column for each pair of equally-named columns..

Specified by:
naturalJoin in interface From<FindQuery<BEAN>>
Returns:

innerJoin

public FindQuery<BEAN> innerJoin(Class<?> joinClass)
Description copied from interface: From
Perform a inner Join. An inner join can be performed in a normal sql query simply using the key JOIN.

Specified by:
innerJoin in interface From<FindQuery<BEAN>>
Returns:

innerJoin

public FindQuery<BEAN> innerJoin(Class<?> joinClass,
                                 String joinClassAlias)
Description copied from interface: From
Perform a inner Join. An inner join can be performed in a normal sql simply using the key JOIN.

Specified by:
innerJoin in interface From<FindQuery<BEAN>>
Returns:

innerJoin

public FindQuery<BEAN> innerJoin(Class<?> joinClass,
                                 String onLeftProperty,
                                 String onRigthProperty)
Description copied from interface: From
Perform a inner Join. An inner join can be performed in a normal sql query simply using the key JOIN.

Specified by:
innerJoin in interface From<FindQuery<BEAN>>
Returns:

innerJoin

public FindQuery<BEAN> innerJoin(Class<?> joinClass,
                                 String joinClassAlias,
                                 String onLeftProperty,
                                 String onRigthProperty)
Description copied from interface: From
Perform a inner Join. An inner join can be performed in a normal sql simply using the key JOIN.

Specified by:
innerJoin in interface From<FindQuery<BEAN>>
Returns:

leftOuterJoin

public FindQuery<BEAN> leftOuterJoin(Class<?> joinClass)
Description copied from interface: From
Perform a natural left outer Join. The name of the class will be used as alias.

Specified by:
leftOuterJoin in interface From<FindQuery<BEAN>>
Returns:

leftOuterJoin

public FindQuery<BEAN> leftOuterJoin(Class<?> joinClass,
                                     String joinClassAlias)
Description copied from interface: From
Perform a natural left outer Join.

Specified by:
leftOuterJoin in interface From<FindQuery<BEAN>>
Returns:

leftOuterJoin

public FindQuery<BEAN> leftOuterJoin(Class<?> joinClass,
                                     String onLeftProperty,
                                     String onRigthProperty)
Description copied from interface: From
Perform a left outer Join.

Specified by:
leftOuterJoin in interface From<FindQuery<BEAN>>
Returns:

leftOuterJoin

public FindQuery<BEAN> leftOuterJoin(Class<?> joinClass,
                                     String joinClassAlias,
                                     String onLeftProperty,
                                     String onRigthProperty)
Description copied from interface: From
Perform left outer Join.

Specified by:
leftOuterJoin in interface From<FindQuery<BEAN>>
Returns:

rightOuterJoin

public FindQuery<BEAN> rightOuterJoin(Class<?> joinClass)
Description copied from interface: From
Perform a natural right outer Join. The name of the class will be used as alias.

Specified by:
rightOuterJoin in interface From<FindQuery<BEAN>>
Returns:

rightOuterJoin

public FindQuery<BEAN> rightOuterJoin(Class<?> joinClass,
                                      String joinClassAlias)
Description copied from interface: From
Perform a natural right outer Join.

Specified by:
rightOuterJoin in interface From<FindQuery<BEAN>>
Returns:

rightOuterJoin

public FindQuery<BEAN> rightOuterJoin(Class<?> joinClass,
                                      String onLeftProperty,
                                      String onRigthProperty)
Description copied from interface: From
Perform a right outer Join.

Specified by:
rightOuterJoin in interface From<FindQuery<BEAN>>
Returns:

rightOuterJoin

public FindQuery<BEAN> rightOuterJoin(Class<?> joinClass,
                                      String joinClassAlias,
                                      String onLeftProperty,
                                      String onRigthProperty)
Description copied from interface: From
Perform right outer Join.

Specified by:
rightOuterJoin in interface From<FindQuery<BEAN>>
Returns:

fullOuterJoin

public FindQuery<BEAN> fullOuterJoin(Class<?> joinClass)
Description copied from interface: From
Perform a natural full outer Join. The name of the class will be used as alias.

Specified by:
fullOuterJoin in interface From<FindQuery<BEAN>>
Returns:

fullOuterJoin

public FindQuery<BEAN> fullOuterJoin(Class<?> joinClass,
                                     String joinClassAlias)
Description copied from interface: From
Perform a natural full outer Join.

Specified by:
fullOuterJoin in interface From<FindQuery<BEAN>>
Returns:

fullOuterJoin

public FindQuery<BEAN> fullOuterJoin(Class<?> joinClass,
                                     String onLeftProperty,
                                     String onRigthProperty)
Description copied from interface: From
Perform a full outer Join.

Specified by:
fullOuterJoin in interface From<FindQuery<BEAN>>
Returns:

fullOuterJoin

public FindQuery<BEAN> fullOuterJoin(Class<?> joinClass,
                                     String joinClassAlias,
                                     String onLeftProperty,
                                     String onRigthProperty)
Description copied from interface: From
Perform full outer Join.

Specified by:
fullOuterJoin in interface From<FindQuery<BEAN>>
Returns:

findList

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

Specified by:
findList in interface FindQueryCommon<BEAN>
Returns:

find

public BEAN find()
          throws OrmException,
                 OrmNotUniqueResultException
Description copied from interface: FindQueryCommon
Execute the query returning either a single bean, if the ResultSet contains at least one row, or null, if no matching beans are found).

Specified by:
find in interface FindQueryCommon<BEAN>
Returns:
Throws:
OrmNotUniqueResultException - if zero or more than one row are returned from the query
OrmException


Copyright © 2013. All Rights Reserved.