com.mysema.query.jpa.hibernate
Class AbstractHibernateQuery<Q extends AbstractHibernateQuery<Q>>

java.lang.Object
  extended by com.mysema.query.support.QueryBase<Q>
      extended by com.mysema.query.support.ProjectableQuery<Q>
          extended by com.mysema.query.jpa.JPQLQueryBase<Q>
              extended by com.mysema.query.jpa.hibernate.AbstractHibernateQuery<Q>
Type Parameters:
Q -
All Implemented Interfaces:
Projectable
Direct Known Subclasses:
HibernateQuery

public abstract class AbstractHibernateQuery<Q extends AbstractHibernateQuery<Q>>
extends JPQLQueryBase<Q>

Abstract base class for Hibernate API based implementations of the JPQL interface

Author:
tiwe

Constructor Summary
AbstractHibernateQuery(org.hibernate.Session session)
           
AbstractHibernateQuery(SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata)
           
 
Method Summary
 long count()
          return the amount of matched rows
 org.hibernate.Query createQuery(Expression<?> expr)
          Expose the original Hibernate query for the given projection
 org.hibernate.Query createQuery(Expression<?>[] args)
          Expose the original Hibernate query for the given projection
 org.hibernate.Query createQuery(Expression<?> expr1, Expression<?> expr2, Expression<?>... rest)
          Expose the original Hibernate query for the given projection
 com.mysema.commons.lang.CloseableIterator<Object[]> iterate(Expression<?>[] args)
          Return the query results as an Iterator.
<RT> com.mysema.commons.lang.CloseableIterator<RT>
iterate(Expression<RT> projection)
          Return the query results as an Iterator.
 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
protected  void logQuery(String queryString)
           
 org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode, Expression<?> expr)
          Return the query results as ScrollableResults.
 org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode, Expression<?>[] args)
          Return the query results as ScrollableResults.
 org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode, Expression<?> expr1, Expression<?> expr2, Expression<?>... rest)
          Return the query results as ScrollableResults.
 Q setCacheable(boolean cacheable)
          Enable caching of this query result set.
 Q setCacheRegion(String cacheRegion)
          Set the name of the cache region.
 Q setFetchSize(int fetchSize)
          Set a fetch size for the underlying JDBC query.
 Q setLockMode(Path<?> path, org.hibernate.LockMode lockMode)
          Set the lock mode for the given path.
 Q setReadOnly(boolean readOnly)
          Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent.
 Q setTimeout(int timeout)
          Set a timeout for the underlying JDBC query.
 Object[] uniqueResult(Expression<?>[] args)
          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.jpa.JPQLQueryBase
buildQueryString, exists, fetch, fetchAll, from, fullJoin, fullJoin, fullJoin, fullJoin, fullJoin, fullJoin, getConstants, getMetadata, getQueryMixin, getTemplates, innerJoin, innerJoin, innerJoin, innerJoin, innerJoin, innerJoin, join, join, join, join, join, join, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, reset, setConstants, toCountRowsString, toQueryString, toString, with
 
Methods inherited from class com.mysema.query.support.ProjectableQuery
countDistinct, iterate, iterateDistinct, iterateDistinct, iterateDistinct, list, listDistinct, listDistinct, listDistinct, listDistinctResults, map, notExists, singleResult, singleResult, singleResult, uniqueResult, uniqueResult
 
Methods inherited from class com.mysema.query.support.QueryBase
distinct, groupBy, having, limit, offset, orderBy, restrict, set, where
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractHibernateQuery

public AbstractHibernateQuery(org.hibernate.Session session)

AbstractHibernateQuery

public AbstractHibernateQuery(SessionHolder session,
                              JPQLTemplates patterns,
                              QueryMetadata metadata)
Method Detail

count

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


createQuery

public org.hibernate.Query createQuery(Expression<?> expr)
Expose the original Hibernate query for the given projection

Parameters:
expr -
Returns:

createQuery

public org.hibernate.Query createQuery(Expression<?> expr1,
                                       Expression<?> expr2,
                                       Expression<?>... rest)
Expose the original Hibernate query for the given projection

Parameters:
expr1 -
expr2 -
rest -
Returns:

createQuery

public org.hibernate.Query createQuery(Expression<?>[] args)
Expose the original Hibernate query for the given projection

Parameters:
args -
Returns:

iterate

public com.mysema.commons.lang.CloseableIterator<Object[]> iterate(Expression<?>[] args)
Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.

Returns:

iterate

public <RT> com.mysema.commons.lang.CloseableIterator<RT> iterate(Expression<RT> projection)
Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.

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 AbstractHibernateQuery<Q>>
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 AbstractHibernateQuery<Q>>
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:

logQuery

protected void logQuery(String queryString)

scroll

public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode,
                                              Expression<?> expr)
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Parameters:
mode -
expr -
Returns:

scroll

public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode,
                                              Expression<?> expr1,
                                              Expression<?> expr2,
                                              Expression<?>... rest)
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Parameters:
mode -
expr1 -
expr2 -
rest -
Returns:

scroll

public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode,
                                              Expression<?>[] args)
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Parameters:
mode -
args -
Returns:

setCacheable

public Q setCacheable(boolean cacheable)
Enable caching of this query result set.

Parameters:
cacheable - Should the query results be cacheable?

setCacheRegion

public Q setCacheRegion(String cacheRegion)
Set the name of the cache region.

Parameters:
cacheRegion - the name of a query cache region, or null for the default query cache

setFetchSize

public Q setFetchSize(int fetchSize)
Set a fetch size for the underlying JDBC query.

Parameters:
fetchSize - the fetch size

setLockMode

public Q setLockMode(Path<?> path,
                     org.hibernate.LockMode lockMode)
Set the lock mode for the given path.


setReadOnly

public Q setReadOnly(boolean readOnly)
Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent.


setTimeout

public Q setTimeout(int timeout)
Set a timeout for the underlying JDBC query.

Parameters:
timeout - the timeout in seconds

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

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

uniqueResult

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

Returns:


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