com.jpattern.orm.query.find
Class CustomFindQueryOrm

java.lang.Object
  extended by com.jpattern.orm.query.SmartRenderableSqlQuery
      extended by com.jpattern.orm.query.find.CustomFindQueryOrm
All Implemented Interfaces:
BaseFindQuery, From<CustomFindQuery>, SqlClause<CustomFindQuery>, CustomQuery, CustomFindFrom, CustomFindQuery, CustomFindQueryCommon, NameSolverConsumer, QueryRoot, RenderableSqlQuery

public class CustomFindQueryOrm
extends SmartRenderableSqlQuery
implements CustomFindQuery, NameSolverConsumer

Author:
Francesco Cina 20/giu/2011

Constructor Summary
CustomFindQueryOrm(String selectClause, IOrmClassToolMap ormClassToolMap, SessionSqlPerformer session, Class<?> clazz, Integer nameSolverClassId, TypeFactory typeFactory)
           
 
Method Summary
 void appendElementValues(List<Object> values)
           
 void appendValues(List<Object> values)
          Append to the list all the values of the expression's elements
 void doElementRender(StringBuilder stringBuilder)
           
 void doRender(StringBuilder stringBuilder)
           
<T> T
find(ResultSetReader<T> rse)
          Execute the query reading the ResultSet with a ResultSetReader.
<T> List<T>
find(ResultSetRowReader<T> rsrr)
          Execute the query reading the ResultSet with a ResultSetRowReader.
 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 query 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).
<T> T
findUnique(ResultSetRowReader<T> rsrr)
          Execute the query reading the ResultSet with a ResultSetRowReader.
 CustomFindQuery fullOuterJoin(Class<?> joinClass)
          Perform a natural full outer Join.
 CustomFindQuery fullOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural full outer Join.
 CustomFindQuery fullOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a full outer Join.
 CustomFindQuery fullOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform full outer Join.
 int getElementStatusVersion()
           
 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()
           
 CustomFindQuery innerJoin(Class<?> joinClass)
          Perform a inner Join.
 CustomFindQuery innerJoin(Class<?> joinClass, String joinClassAlias)
          Perform a inner Join.
 CustomFindQuery innerJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a inner Join.
 CustomFindQuery innerJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform a inner Join.
 boolean isDistinct()
          return if use Distinct in the select clause
 boolean isElementStatusChanged()
           
 CustomFindQuery join(Class<?> joinClass)
          Perform a simple (cross) Join.
 CustomFindQuery join(Class<?> joinClass, String joinClassAlias)
          Perform a simple (cross) Join.
 CustomFindQuery leftOuterJoin(Class<?> joinClass)
          Perform a natural left outer Join.
 CustomFindQuery leftOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural left outer Join.
 CustomFindQuery leftOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a left outer Join.
 CustomFindQuery leftOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform left outer Join.
 CustomFindQuery naturalJoin(Class<?> joinClass)
          Perform a natural Join.
 CustomFindQuery naturalJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural Join.
 CustomFindOrderBy orderBy()
          Set the order by clause.
 String renderSqlElement()
           
 void renderSqlElement(StringBuilder stringBuilder)
           
 CustomFindQuery rightOuterJoin(Class<?> joinClass)
          Perform a natural right outer Join.
 CustomFindQuery rightOuterJoin(Class<?> joinClass, String joinClassAlias)
          Perform a natural right outer Join.
 CustomFindQuery rightOuterJoin(Class<?> joinClass, String onLeftProperty, String onRigthProperty)
          Perform a right outer Join.
 CustomFindQuery rightOuterJoin(Class<?> joinClass, String joinClassAlias, String onLeftProperty, String onRigthProperty)
          Perform right outer Join.
 CustomFindQuery setDistinct(boolean distinct)
          Whether to use Distinct in the select clause
 CustomFindQuery setLockMode(LockMode lockMode)
           
 CustomFindQuery setMaxRows(int maxRows)
          Set the maximum number of rows to return in the query.
 void setNameSolver(NameSolver nameSolver)
           
 CustomFindQuery setQueryTimeout(int queryTimeout)
          Set the query timeout for the query.
 String toString()
           
 CustomFindWhere 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, wait, wait, wait
 
Methods inherited from interface com.jpattern.orm.query.RenderableSqlQuery
renderSql, renderSql
 

Constructor Detail

CustomFindQueryOrm

public CustomFindQueryOrm(String selectClause,
                          IOrmClassToolMap ormClassToolMap,
                          SessionSqlPerformer session,
                          Class<?> clazz,
                          Integer nameSolverClassId,
                          TypeFactory typeFactory)
Method Detail

setNameSolver

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

findList

public List<Object[]> findList()
Description copied from interface: CustomQuery
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 CustomQuery
Returns:

findUnique

public Object[] findUnique()
                    throws OrmNotUniqueResultException
Description copied from interface: CustomQuery
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 CustomQuery
Returns:
Throws:
OrmNotUniqueResultException - if not exactly one row is returned from the query

getStatusVersion

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

doRender

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

find

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

Specified by:
find in interface CustomQuery
Returns:
an arbitrary result object, as returned by the ResultSetReader
Throws:
OrmException

find

public <T> List<T> find(ResultSetRowReader<T> rsrr)
             throws OrmException
Description copied from interface: CustomQuery
Execute the query reading the ResultSet with a ResultSetRowReader.

Specified by:
find in interface CustomQuery
Parameters:
rsrr - object that will extract all rows of results
Returns:
a List of result objects returned by the ResultSetRowReader
Throws:
OrmException

findUnique

public <T> T findUnique(ResultSetRowReader<T> rsrr)
             throws OrmException,
                    OrmNotUniqueResultException
Description copied from interface: CustomQuery
Execute the query reading the ResultSet with a ResultSetRowReader.

Specified by:
findUnique in interface CustomQuery
Parameters:
rsrr - object that will extract the row of result
Returns:
Throws:
OrmException
OrmNotUniqueResultException - if the results of the query executions are not exactly 1

findInt

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

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

findLong

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

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

findDouble

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

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

findFloat

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

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

findString

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

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

findBoolean

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

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

findBigDecimal

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

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

getMaxRows

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

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

setQueryTimeout

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

Specified by:
setQueryTimeout in interface CustomFindQueryCommon

getQueryTimeout

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

Specified by:
getQueryTimeout in interface CustomFindQueryCommon

setMaxRows

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

Specified by:
setMaxRows in interface CustomFindQueryCommon
Returns:
Throws:
OrmException

setLockMode

public CustomFindQuery setLockMode(LockMode lockMode)
Specified by:
setLockMode in interface CustomFindQueryCommon
Returns:

getLockMode

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

Specified by:
getLockMode in interface CustomFindQueryCommon
Returns:

where

public final CustomFindWhere where()
                            throws OrmException
Description copied from interface: CustomFindQuery
Set the where clause.

Specified by:
where in interface CustomFindQuery
Returns:
Throws:
OrmException

orderBy

public final CustomFindOrderBy orderBy()
                                throws OrmException
Description copied from interface: CustomFindQuery
Set the order by clause.

Specified by:
orderBy in interface CustomFindQuery
Returns:
Throws:
OrmException

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

renderSqlElement

public final String renderSqlElement()

renderSqlElement

public final void renderSqlElement(StringBuilder stringBuilder)

isElementStatusChanged

public final boolean isElementStatusChanged()

join

public CustomFindQuery 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<CustomFindQuery>
Returns:

join

public CustomFindQuery 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<CustomFindQuery>
Returns:

naturalJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

naturalJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

innerJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

innerJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

innerJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

innerJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

leftOuterJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

leftOuterJoin

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

Specified by:
leftOuterJoin in interface From<CustomFindQuery>
Returns:

leftOuterJoin

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

Specified by:
leftOuterJoin in interface From<CustomFindQuery>
Returns:

leftOuterJoin

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

Specified by:
leftOuterJoin in interface From<CustomFindQuery>
Returns:

rightOuterJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

rightOuterJoin

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

Specified by:
rightOuterJoin in interface From<CustomFindQuery>
Returns:

rightOuterJoin

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

Specified by:
rightOuterJoin in interface From<CustomFindQuery>
Returns:

rightOuterJoin

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

Specified by:
rightOuterJoin in interface From<CustomFindQuery>
Returns:

fullOuterJoin

public CustomFindQuery 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<CustomFindQuery>
Returns:

fullOuterJoin

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

Specified by:
fullOuterJoin in interface From<CustomFindQuery>
Returns:

fullOuterJoin

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

Specified by:
fullOuterJoin in interface From<CustomFindQuery>
Returns:

fullOuterJoin

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

Specified by:
fullOuterJoin in interface From<CustomFindQuery>
Returns:

getElementStatusVersion

public final int getElementStatusVersion()

doElementRender

public final void doElementRender(StringBuilder stringBuilder)

appendElementValues

public final void appendElementValues(List<Object> values)

toString

public String toString()
Overrides:
toString in class Object

setDistinct

public CustomFindQuery setDistinct(boolean distinct)
Description copied from interface: CustomFindQueryCommon
Whether to use Distinct in the select clause

Specified by:
setDistinct in interface CustomFindQueryCommon
Returns:

isDistinct

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

Specified by:
isDistinct in interface CustomFindQueryCommon
Returns:
Throws:
OrmException


Copyright © 2013. All Rights Reserved.