com.mysema.query.support
Class ProjectableQuery<Q extends ProjectableQuery<Q>>

java.lang.Object
  extended by com.mysema.query.support.QueryBase<Q>
      extended by com.mysema.query.support.ProjectableQuery<Q>
All Implemented Interfaces:
Projectable
Direct Known Subclasses:
AbstractColQuery, AbstractJDOQLQuery, AbstractSQLQuery, AbstractSQLQuery, AbstractSQLQuery, JPQLQueryBase

public abstract class ProjectableQuery<Q extends ProjectableQuery<Q>>
extends QueryBase<Q>
implements Projectable

ProjectableQuery extends the QueryBase class to provide default implementations of the methods of the Projectable interface

Author:
tiwe

Field Summary
 
Fields inherited from class com.mysema.query.support.QueryBase
queryMixin
 
Constructor Summary
ProjectableQuery(QueryMixin<Q> queryMixin)
           
 
Method Summary
 long countDistinct()
          return the amount of distinct matched rows
 com.mysema.commons.lang.CloseableIterator<Object[]> iterate(Expression<?> first, Expression<?> second, Expression<?>... rest)
          iterate over the results for the given projection
 com.mysema.commons.lang.CloseableIterator<Object[]> iterateDistinct(Expression<?>[] args)
          iterate over the distinct results for the given projection
 com.mysema.commons.lang.CloseableIterator<Object[]> iterateDistinct(Expression<?> first, Expression<?> second, Expression<?>... rest)
          iterate over the distinct results for the given projection
<RT> com.mysema.commons.lang.CloseableIterator<RT>
iterateDistinct(Expression<RT> projection)
          iterate over the distinct results for the given projection
 List<Object[]> list(Expression<?>[] args)
          list the results for the given projection An empty list is returned for no results.
 List<Object[]> list(Expression<?> first, Expression<?> second, Expression<?>... rest)
          list the results for the given projection An empty list is returned for no results.
<RT> List<RT>
list(Expression<RT> projection)
          list the results for the given projection An empty list is returned for no results.
 List<Object[]> listDistinct(Expression<?>[] args)
          list the distinct results for the given projection An empty list is returned for no results.
 List<Object[]> listDistinct(Expression<?> first, Expression<?> second, Expression<?>... rest)
          list the distinct results for the given projection An empty list is returned for no results.
<RT> List<RT>
listDistinct(Expression<RT> projection)
          list the distinct results for the given projection An empty list is returned for no results.
<RT> SearchResults<RT>
listDistinctResults(Expression<RT> projection)
          list the distinct results for the given projection
<K,V> Map<K,V>
map(Expression<K> key, Expression<V> value)
          return the given projection as a Map instance using key and value for Map population An empty map is returned for no results.
 boolean notExists()
           
 Object[] singleResult(Expression<?>[] args)
          return a single result for the given projection or null if no result is found
 Object[] singleResult(Expression<?> first, Expression<?> second, Expression<?>... rest)
          return a single result for the given projection or null if no result is found
<RT> RT
singleResult(Expression<RT> expr)
          return a single result for the given projection or null if no result is found
<T> T
transform(ResultTransformer<T> transformer)
          Apply the given transformer to this Projectable instance and return the results
protected
<T> T
uniqueResult(com.mysema.commons.lang.CloseableIterator<T> it)
           
 Object[] uniqueResult(Expression<?> first, Expression<?> second, Expression<?>... rest)
          return a unique result for the given projection or null if no result is found
 
Methods inherited from class com.mysema.query.support.QueryBase
distinct, equals, groupBy, hashCode, having, limit, offset, orderBy, restrict, set, toString, where
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.mysema.query.Projectable
count, exists, iterate, iterate, listResults, uniqueResult, uniqueResult
 

Constructor Detail

ProjectableQuery

public ProjectableQuery(QueryMixin<Q> queryMixin)
Method Detail

countDistinct

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

Specified by:
countDistinct in interface Projectable

iterate

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

Specified by:
iterate in interface Projectable
Returns:
an Iterator over the projection

iterateDistinct

public final com.mysema.commons.lang.CloseableIterator<Object[]> iterateDistinct(Expression<?> first,
                                                                                 Expression<?> second,
                                                                                 Expression<?>... rest)
Description copied from interface: Projectable
iterate over the distinct results for the given projection

Specified by:
iterateDistinct in interface Projectable
Returns:
an Iterator over the projection

iterateDistinct

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

Specified by:
iterateDistinct in interface Projectable
Returns:

iterateDistinct

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

Specified by:
iterateDistinct in interface Projectable
Type Parameters:
RT - generic type of the Iteratpr
Returns:
an Iterator over the projection

list

public final List<Object[]> list(Expression<?> first,
                                 Expression<?> second,
                                 Expression<?>... rest)
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
rest - rest
Returns:
a List 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
Returns:

list

public <RT> List<RT> list(Expression<RT> projection)
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
Type Parameters:
RT - generic type of the List
Returns:
a List over the projection

listDistinct

public final List<Object[]> listDistinct(Expression<?> first,
                                         Expression<?> second,
                                         Expression<?>... rest)
Description copied from interface: Projectable
list the distinct results for the given projection An empty list is returned for no results.

Specified by:
listDistinct in interface Projectable
rest - rest
Returns:
a List over the projection

listDistinct

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

Specified by:
listDistinct in interface Projectable
Returns:

listDistinct

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

Specified by:
listDistinct in interface Projectable
Type Parameters:
RT - generic type of the List
Returns:
a List over the projection

listDistinctResults

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

Specified by:
listDistinctResults in interface Projectable
Returns:

map

public final <K,V> Map<K,V> map(Expression<K> key,
                                Expression<V> value)
Description copied from interface: Projectable
return the given projection as a Map instance using key and value for Map population An empty map is returned for no results.

Specified by:
map in interface Projectable
Returns:

notExists

public final boolean notExists()
Specified by:
notExists in interface Projectable
Returns:
true, if no rows matching the given criteria exist, otherwise false

singleResult

public final Object[] singleResult(Expression<?> first,
                                   Expression<?> second,
                                   Expression<?>... rest)
Description copied from interface: Projectable
return a single result for the given projection or null if no result is found

for multiple results only the first one is returned

Specified by:
singleResult in interface Projectable
Returns:

singleResult

public final Object[] singleResult(Expression<?>[] args)
Description copied from interface: Projectable
return a single 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.

for multiple results only the first one is returned

Specified by:
singleResult in interface Projectable
Returns:

singleResult

public final <RT> RT singleResult(Expression<RT> expr)
Description copied from interface: Projectable
return a single 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.

for multiple results only the first one is returned

Specified by:
singleResult in interface Projectable
Type Parameters:
RT - return type
Returns:
the result or null for an empty result

transform

public <T> T transform(ResultTransformer<T> transformer)
Description copied from interface: Projectable
Apply the given transformer to this Projectable instance and return the results

Specified by:
transform in interface Projectable
Returns:

uniqueResult

public final Object[] uniqueResult(Expression<?> first,
                                   Expression<?> second,
                                   Expression<?>... rest)
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.

Specified by:
uniqueResult in interface Projectable
Returns:

uniqueResult

@Nullable
protected <T> T uniqueResult(com.mysema.commons.lang.CloseableIterator<T> it)


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