com.mysema.query.sql
Class AbstractSQLQuery<Q extends AbstractSQLQuery<Q> & Query>

java.lang.Object
  extended by com.mysema.query.support.QueryBase<Q>
      extended by com.mysema.query.support.ProjectableQuery<Q>
          extended by com.mysema.query.sql.AbstractSQLQuery<Q>
All Implemented Interfaces:
Projectable
Direct Known Subclasses:
MySQLQuery, OracleQuery, PostgresQuery, SQLQueryImpl, SQLServerQuery

public abstract class AbstractSQLQuery<Q extends AbstractSQLQuery<Q> & Query>
extends ProjectableQuery<Q>

AbstractSQLQuery is the base type for SQL query implementations

Author:
tiwe

Field Summary
protected  SQLQueryMixin<Q> queryMixin
           
protected  SubQueryExpression<?>[] union
           
protected  boolean unionAll
           
 
Constructor Summary
AbstractSQLQuery(Connection conn, Configuration configuration)
           
AbstractSQLQuery(Connection conn, Configuration configuration, QueryMetadata metadata)
           
 
Method Summary
 Q addFlag(QueryFlag.Position position, Expression<?> flag)
          Add the given Expression as a query flag
 Q addFlag(QueryFlag.Position position, String flag)
          Add the given String literal as query flag
 Q addFlag(QueryFlag.Position position, String prefix, Expression<?> expr)
          Add the given prefix and expression as a general query flag
 Q addJoinFlag(String flag)
          Add the given String literal as a join flag to the last added join with the position BEFORE_TARGET
 Q addJoinFlag(String flag, JoinFlag.Position position)
          Add the given String literal as a join flag to the last added join
protected  String buildQueryString(boolean forCountRow)
           
 long count()
          return the amount of matched rows
protected  SQLSerializer createSerializer()
           
 boolean exists()
           
 Q forUpdate()
           
 Q from(Expression<?>... args)
           
 Q from(SubQueryExpression<?> subQuery, Path<?> alias)
           
<E> Q
fullJoin(ForeignKey<E> key, RelationalPath<E> entity)
           
<E> Q
fullJoin(RelationalFunctionCall<E> target, Path<E> alias)
           
 Q fullJoin(RelationalPath<?> target)
           
 Q fullJoin(SubQueryExpression<?> target, Path<?> alias)
           
protected  Configuration getConfiguration()
           
 QueryMetadata getMetadata()
           
 ResultSet getResults(Expression<?>... exprs)
           
<E> Q
innerJoin(ForeignKey<E> key, RelationalPath<E> entity)
           
<E> Q
innerJoin(RelationalFunctionCall<E> target, Path<E> alias)
           
 Q innerJoin(RelationalPath<?> target)
           
 Q innerJoin(SubQueryExpression<?> target, Path<?> alias)
           
 com.mysema.commons.lang.CloseableIterator<Object[]> iterate(Expression<?>[] args)
          iterate over the results for the given projection
<RT> com.mysema.commons.lang.CloseableIterator<RT>
iterate(Expression<RT> expr)
          iterate over the results for the given projection
<E> Q
join(ForeignKey<E> key, RelationalPath<E> entity)
           
<E> Q
join(RelationalFunctionCall<E> target, Path<E> alias)
           
 Q join(RelationalPath<?> target)
           
 Q join(SubQueryExpression<?> target, Path<?> alias)
           
<E> Q
leftJoin(ForeignKey<E> key, RelationalPath<E> entity)
           
<E> Q
leftJoin(RelationalFunctionCall<E> target, Path<E> alias)
           
 Q leftJoin(RelationalPath<?> target)
           
 Q leftJoin(SubQueryExpression<?> target, Path<?> alias)
           
 List<Object[]> list(Expression<?>[] args)
          list the results for the given projection An empty list is returned for no results.
<RT> List<RT>
list(Expression<RT> expr)
          list the results for the given projection An empty list is returned for no results.
<RT> SearchResults<RT>
listResults(Expression<RT> expr)
          list the results for the given projection
 Q on(Predicate... conditions)
           
<E> Q
rightJoin(ForeignKey<E> key, RelationalPath<E> entity)
           
<E> Q
rightJoin(RelationalFunctionCall<E> target, Path<E> alias)
           
 Q rightJoin(RelationalPath<?> target)
           
 Q rightJoin(SubQueryExpression<?> target, Path<?> alias)
           
protected  void setParameters(PreparedStatement stmt, List<?> objects, List<Path<?>> constantPaths, Map<ParamExpression<?>,?> params)
           
 String toString()
           
<RT> Union<RT>
union(ListSubQuery<RT>... sq)
           
<RT> Q
union(Path<?> alias, ListSubQuery<RT>... sq)
           
<RT> Q
union(Path<?> alias, SubQueryExpression<RT>... sq)
           
<RT> Union<RT>
union(SubQueryExpression<RT>... sq)
           
<RT> Union<RT>
unionAll(ListSubQuery<RT>... sq)
           
<RT> Q
unionAll(Path<?> alias, ListSubQuery<RT>... sq)
           
<RT> Q
unionAll(Path<?> alias, SubQueryExpression<RT>... sq)
           
<RT> Union<RT>
unionAll(SubQueryExpression<RT>... sq)
           
 Object[] uniqueResult(Expression<?>[] expr)
          return a unique result for the given projection or null if no result is found
<RT> RT
uniqueResult(Expression<RT> expr)
          return a unique result for the given projection or null if no result is found
 
Methods inherited from class com.mysema.query.support.ProjectableQuery
countDistinct, iterate, iterateDistinct, iterateDistinct, iterateDistinct, list, listDistinct, listDistinct, listDistinct, listDistinctResults, map, notExists, singleResult, singleResult, singleResult, transform, uniqueResult, uniqueResult
 
Methods inherited from class com.mysema.query.support.QueryBase
distinct, equals, groupBy, hashCode, having, limit, offset, orderBy, restrict, set, where
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

union

@Nullable
protected SubQueryExpression<?>[] union

queryMixin

protected final SQLQueryMixin<Q extends AbstractSQLQuery<Q> & Query> queryMixin

unionAll

protected boolean unionAll
Constructor Detail

AbstractSQLQuery

public AbstractSQLQuery(@Nullable
                        Connection conn,
                        Configuration configuration)

AbstractSQLQuery

public AbstractSQLQuery(@Nullable
                        Connection conn,
                        Configuration configuration,
                        QueryMetadata metadata)
Method Detail

addJoinFlag

public Q addJoinFlag(String flag)
Add the given String literal as a join flag to the last added join with the position BEFORE_TARGET

Parameters:
flag -
Returns:

addJoinFlag

public Q addJoinFlag(String flag,
                     JoinFlag.Position position)
Add the given String literal as a join flag to the last added join

Parameters:
flag -
position -
Returns:

addFlag

public Q addFlag(QueryFlag.Position position,
                 String prefix,
                 Expression<?> expr)
Add the given prefix and expression as a general query flag

Parameters:
position - position of the flag
prefix - prefix for the flag
expr - expression of the flag
Returns:

addFlag

public Q addFlag(QueryFlag.Position position,
                 String flag)
Add the given String literal as query flag

Parameters:
position -
flag -
Returns:

addFlag

public Q addFlag(QueryFlag.Position position,
                 Expression<?> flag)
Add the given Expression as a query flag

Parameters:
position -
flag -
Returns:

buildQueryString

protected String buildQueryString(boolean forCountRow)

count

public long count()
Description copied from interface: Projectable
return the amount of matched rows


exists

public boolean exists()
Returns:
true, if rows matching the given criteria exist, otherwise false

forUpdate

public Q forUpdate()

createSerializer

protected SQLSerializer createSerializer()

from

public Q from(Expression<?>... args)

from

public Q from(SubQueryExpression<?> subQuery,
              Path<?> alias)

fullJoin

public Q fullJoin(RelationalPath<?> target)

fullJoin

public <E> Q fullJoin(RelationalFunctionCall<E> target,
                      Path<E> alias)

fullJoin

public Q fullJoin(SubQueryExpression<?> target,
                  Path<?> alias)

fullJoin

public <E> Q fullJoin(ForeignKey<E> key,
                      RelationalPath<E> entity)

innerJoin

public Q innerJoin(RelationalPath<?> target)

innerJoin

public <E> Q innerJoin(RelationalFunctionCall<E> target,
                       Path<E> alias)

innerJoin

public Q innerJoin(SubQueryExpression<?> target,
                   Path<?> alias)

innerJoin

public <E> Q innerJoin(ForeignKey<E> key,
                       RelationalPath<E> entity)

join

public Q join(RelationalPath<?> target)

join

public <E> Q join(RelationalFunctionCall<E> target,
                  Path<E> alias)

join

public Q join(SubQueryExpression<?> target,
              Path<?> alias)

join

public <E> Q join(ForeignKey<E> key,
                  RelationalPath<E> entity)

leftJoin

public Q leftJoin(RelationalPath<?> target)

leftJoin

public <E> Q leftJoin(RelationalFunctionCall<E> target,
                      Path<E> alias)

leftJoin

public Q leftJoin(SubQueryExpression<?> target,
                  Path<?> alias)

leftJoin

public <E> Q leftJoin(ForeignKey<E> key,
                      RelationalPath<E> entity)

rightJoin

public Q rightJoin(RelationalPath<?> target)

rightJoin

public <E> Q rightJoin(RelationalFunctionCall<E> target,
                       Path<E> alias)

rightJoin

public Q rightJoin(SubQueryExpression<?> target,
                   Path<?> alias)

rightJoin

public <E> Q rightJoin(ForeignKey<E> key,
                       RelationalPath<E> entity)

getMetadata

public QueryMetadata getMetadata()

getResults

public ResultSet getResults(Expression<?>... exprs)

getConfiguration

protected Configuration getConfiguration()

iterate

public com.mysema.commons.lang.CloseableIterator<Object[]> iterate(Expression<?>[] args)
Description copied from interface: Projectable
iterate over the results for the given projection

Returns:

iterate

public <RT> com.mysema.commons.lang.CloseableIterator<RT> iterate(Expression<RT> expr)
Description copied from interface: Projectable
iterate over the results for the given projection

Type Parameters:
RT - generic type of the Iterator
Returns:
an Iterator over the projection

list

public List<Object[]> list(Expression<?>[] args)
Description copied from interface: Projectable
list the results for the given projection An empty list is returned for no results.

Specified by:
list in interface Projectable
Overrides:
list in class ProjectableQuery<Q extends AbstractSQLQuery<Q> & Query>
Returns:

list

public <RT> List<RT> list(Expression<RT> expr)
Description copied from interface: Projectable
list the results for the given projection An empty list is returned for no results.

Specified by:
list in interface Projectable
Overrides:
list in class ProjectableQuery<Q extends AbstractSQLQuery<Q> & Query>
Type Parameters:
RT - generic type of the List
Returns:
a List over the projection

listResults

public <RT> SearchResults<RT> listResults(Expression<RT> expr)
Description copied from interface: Projectable
list the results for the given projection

Returns:

on

public Q on(Predicate... conditions)

setParameters

protected void setParameters(PreparedStatement stmt,
                             List<?> objects,
                             List<Path<?>> constantPaths,
                             Map<ParamExpression<?>,?> params)

toString

public String toString()
Overrides:
toString in class QueryBase<Q extends AbstractSQLQuery<Q> & Query>

union

public <RT> Union<RT> union(ListSubQuery<RT>... sq)

union

public <RT> Q union(Path<?> alias,
                    ListSubQuery<RT>... sq)

union

public <RT> Union<RT> union(SubQueryExpression<RT>... sq)

union

public <RT> Q union(Path<?> alias,
                    SubQueryExpression<RT>... sq)

unionAll

public <RT> Union<RT> unionAll(ListSubQuery<RT>... sq)

unionAll

public <RT> Q unionAll(Path<?> alias,
                       ListSubQuery<RT>... sq)

unionAll

public <RT> Union<RT> unionAll(SubQueryExpression<RT>... sq)

unionAll

public <RT> Q unionAll(Path<?> alias,
                       SubQueryExpression<RT>... sq)

uniqueResult

public <RT> RT uniqueResult(Expression<RT> expr)
Description copied from interface: Projectable
return a unique result for the given projection or null if no result is found

There is some ambiguity for missing results and null valued results, for disambiguation use the list or iterate methods instead.

Type Parameters:
RT - return type
Returns:
the result or null for an empty result

uniqueResult

public Object[] uniqueResult(Expression<?>[] expr)
Description copied from interface: Projectable
return a unique result for the given projection or null if no result is found

There is some ambiguity for missing results and null valued results, for disambiguation use the list or iterate methods instead.

Returns:


Copyright © 2007-2012 Mysema Ltd. All Rights Reserved.