org.hibernate.search.jpa.impl
Class FullTextQueryImpl

java.lang.Object
  extended by org.hibernate.search.jpa.impl.FullTextQueryImpl
All Implemented Interfaces:
javax.persistence.Query, FullTextQuery, ProjectionConstants

public class FullTextQueryImpl
extends Object
implements FullTextQuery

Author:
Emmanuel Bernard

Field Summary
 
Fields inherited from interface org.hibernate.search.ProjectionConstants
BOOST, DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, THIS
 
Constructor Summary
FullTextQueryImpl(FullTextQuery query, org.hibernate.Session session)
           
 
Method Summary
 void disableFullTextFilter(String name)
          Disable a given filter by its name
 FullTextFilter enableFullTextFilter(String name)
          Enable a given filter by its name.
 int executeUpdate()
           
 org.apache.lucene.search.Explanation explain(int documentId)
          Return the Lucene Explanation object describing the score computation for the matching object/document in the current query
 List getResultList()
           
 int getResultSize()
          Returns the number of hits for this search Caution: The number of results might be slightly different from getResultList().size() because getResultList() may be not in sync with the database at the time of query.
 Object getSingleResult()
           
 FullTextQuery setCriteriaQuery(org.hibernate.Criteria criteria)
          Defines the Database Query used to load the Lucene results.
 FullTextQuery setFilter(org.apache.lucene.search.Filter filter)
          Allows to use lucene filters.
 javax.persistence.Query setFirstResult(int firstResult)
           
 javax.persistence.Query setFlushMode(javax.persistence.FlushModeType flushMode)
           
 javax.persistence.Query setHint(String hintName, Object value)
           
 javax.persistence.Query setMaxResults(int maxResult)
           
 javax.persistence.Query setParameter(int position, Calendar value, javax.persistence.TemporalType temporalType)
           
 javax.persistence.Query setParameter(int position, Date value, javax.persistence.TemporalType temporalType)
           
 javax.persistence.Query setParameter(int position, Object value)
           
 javax.persistence.Query setParameter(String name, Calendar value, javax.persistence.TemporalType temporalType)
           
 javax.persistence.Query setParameter(String name, Date value, javax.persistence.TemporalType temporalType)
           
 javax.persistence.Query setParameter(String name, Object value)
           
 FullTextQuery setProjection(String... fields)
          Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row" (similar to an HQL or a Criteria API projection).
 FullTextQuery setResultTransformer(org.hibernate.transform.ResultTransformer transformer)
          defines a result transformer used during projection
 FullTextQuery setSort(org.apache.lucene.search.Sort sort)
          Allows to let lucene sort the results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FullTextQueryImpl

public FullTextQueryImpl(FullTextQuery query,
                         org.hibernate.Session session)
Method Detail

setSort

public FullTextQuery setSort(org.apache.lucene.search.Sort sort)
Description copied from interface: FullTextQuery
Allows to let lucene sort the results. This is useful when you have additional sort requirements on top of the default lucene ranking. Without lucene sorting you would have to retrieve the full result set and order the hibernate objects.

Specified by:
setSort in interface FullTextQuery
Parameters:
sort - The lucene sort object.
Returns:
this for method chaining

setFilter

public FullTextQuery setFilter(org.apache.lucene.search.Filter filter)
Description copied from interface: FullTextQuery
Allows to use lucene filters. Semi-deprecated? a preferred way is to use the @FullTextFilterDef approach

Specified by:
setFilter in interface FullTextQuery
Parameters:
filter - The lucene filter.
Returns:
this for method chaining

getResultSize

public int getResultSize()
Description copied from interface: FullTextQuery
Returns the number of hits for this search Caution: The number of results might be slightly different from getResultList().size() because getResultList() may be not in sync with the database at the time of query.

Specified by:
getResultSize in interface FullTextQuery

setCriteriaQuery

public FullTextQuery setCriteriaQuery(org.hibernate.Criteria criteria)
Description copied from interface: FullTextQuery
Defines the Database Query used to load the Lucene results. Useful to load a given object graph by refining the fetch modes No projection (criteria.setProjection() ) allowed, the root entity must be the only returned type No where restriction can be defined either.

Specified by:
setCriteriaQuery in interface FullTextQuery

setProjection

public FullTextQuery setProjection(String... fields)
Description copied from interface: FullTextQuery
Defines the Lucene field names projected and returned in a query result Each field is converted back to it's object representation, an Object[] being returned for each "row" (similar to an HQL or a Criteria API projection). A projectable field must be stored in the Lucene index and use a TwoWayFieldBridge Unless notified in their JavaDoc, all built-in bridges are two-way. All @DocumentId fields are projectable by design. If the projected field is not a projectable field, null is returned in the object[]

Specified by:
setProjection in interface FullTextQuery

enableFullTextFilter

public FullTextFilter enableFullTextFilter(String name)
Description copied from interface: FullTextQuery
Enable a given filter by its name. Returns a FullTextFilter object that allows filter parameter injection

Specified by:
enableFullTextFilter in interface FullTextQuery

disableFullTextFilter

public void disableFullTextFilter(String name)
Description copied from interface: FullTextQuery
Disable a given filter by its name

Specified by:
disableFullTextFilter in interface FullTextQuery

setResultTransformer

public FullTextQuery setResultTransformer(org.hibernate.transform.ResultTransformer transformer)
Description copied from interface: FullTextQuery
defines a result transformer used during projection

Specified by:
setResultTransformer in interface FullTextQuery

getResultList

public List getResultList()
Specified by:
getResultList in interface javax.persistence.Query

getSingleResult

public Object getSingleResult()
Specified by:
getSingleResult in interface javax.persistence.Query

setMaxResults

public javax.persistence.Query setMaxResults(int maxResult)
Specified by:
setMaxResults in interface javax.persistence.Query

setFirstResult

public javax.persistence.Query setFirstResult(int firstResult)
Specified by:
setFirstResult in interface javax.persistence.Query

explain

public org.apache.lucene.search.Explanation explain(int documentId)
Description copied from interface: FullTextQuery
Return the Lucene Explanation object describing the score computation for the matching object/document in the current query

Specified by:
explain in interface FullTextQuery
Parameters:
documentId - Lucene Document id to be explain. This is NOT the object id
Returns:
Lucene Explanation

executeUpdate

public int executeUpdate()
Specified by:
executeUpdate in interface javax.persistence.Query

setHint

public javax.persistence.Query setHint(String hintName,
                                       Object value)
Specified by:
setHint in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(String name,
                                            Object value)
Specified by:
setParameter in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(String name,
                                            Date value,
                                            javax.persistence.TemporalType temporalType)
Specified by:
setParameter in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(String name,
                                            Calendar value,
                                            javax.persistence.TemporalType temporalType)
Specified by:
setParameter in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(int position,
                                            Object value)
Specified by:
setParameter in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(int position,
                                            Date value,
                                            javax.persistence.TemporalType temporalType)
Specified by:
setParameter in interface javax.persistence.Query

setParameter

public javax.persistence.Query setParameter(int position,
                                            Calendar value,
                                            javax.persistence.TemporalType temporalType)
Specified by:
setParameter in interface javax.persistence.Query

setFlushMode

public javax.persistence.Query setFlushMode(javax.persistence.FlushModeType flushMode)
Specified by:
setFlushMode in interface javax.persistence.Query


Copyright © 2011 Hibernate. All Rights Reserved.