Package org.hibernate.search.jpa.impl
Class FullTextQueryImpl
java.lang.Object
org.hibernate.search.jpa.impl.FullTextQueryImpl
- All Implemented Interfaces:
javax.persistence.Query,FullTextQuery,ProjectionConstants
Implements JPA 2 query interface and delegate the call to
a Hibernate Core FullTextQuery.
This has the consequence of "duplicating" the JPA 2 query logic in some areas.
-
Field Summary
Fields inherited from interface org.hibernate.search.ProjectionConstants
BOOST, DOCUMENT, DOCUMENT_ID, EXPLANATION, ID, OBJECT_CLASS, SCORE, THIS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddisableFullTextFilter(String name) Disable a given filter by its nameenableFullTextFilter(String name) Enable a given filter by its name.intexplain(int documentId) Return the LuceneExplanationobject describing the score computation for the matching object/document in the current queryintgetHints()intgetParameter(int position) <T> javax.persistence.Parameter<T> getParameter(int position, Class<T> type) getParameter(String name) <T> javax.persistence.Parameter<T> getParameter(String name, Class<T> type) getParameterValue(int position) getParameterValue(String name) <T> TgetParameterValue(javax.persistence.Parameter<T> param) intReturns the number of hits for this search Caution: The number of results might be slightly different fromgetResultList().size()because getResultList() may be not in sync with the database at the time of query.boolean*Experimental* API, subject to change or removal When usingFullTextQuery.limitExecutionTimeTo(long, java.util.concurrent.TimeUnit)}, returns true if partial results are returned (ie if the time limit has been reached and the result fetching process has been terminated.initializeObjectsWith(ObjectLookupMethod lookupMethod, DatabaseRetrievalMethod retrievalMethod) Refine the strategies used to load entities.booleanisBound(javax.persistence.Parameter<?> param) limitExecutionTimeTo(long timeout, TimeUnit timeUnit) *Experimental* API, subject to change or removal Limit the time used by Hibernate Search to execute the query.setCriteriaQuery(org.hibernate.Criteria criteria) Defines the Database Query used to load the Lucene results.Allows to use lucene filters.setFirstResult(int firstResult) setFlushMode(javax.persistence.FlushModeType flushMode) setLockMode(javax.persistence.LockModeType lockModeType) setMaxResults(int maxResults) setParameter(int position, Object value) setParameter(int position, Calendar value, javax.persistence.TemporalType temporalType) setParameter(int position, Date value, javax.persistence.TemporalType temporalType) setParameter(String name, Object value) setParameter(String name, Calendar value, javax.persistence.TemporalType temporalType) setParameter(String name, Date value, javax.persistence.TemporalType temporalType) setParameter(javax.persistence.Parameter<Calendar> calendarParameter, Calendar calendar, javax.persistence.TemporalType temporalType) setParameter(javax.persistence.Parameter<Date> dateParameter, Date date, javax.persistence.TemporalType temporalType) setParameter(javax.persistence.Parameter<T> tParameter, T t) 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).defines a result transformer used during projectionAllows to let lucene sort the results.<T> T
-
Constructor Details
-
FullTextQueryImpl
-
-
Method Details
-
setSort
Description copied from interface:FullTextQueryAllows 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:
setSortin interfaceFullTextQuery- Parameters:
sort- The lucene sort object.- Returns:
- this for method chaining
-
setFilter
Description copied from interface:FullTextQueryAllows to use lucene filters. Semi-deprecated? a preferred way is to use the @FullTextFilterDef approach- Specified by:
setFilterin interfaceFullTextQuery- Parameters:
filter- The lucene filter.- Returns:
- this for method chaining
-
getResultSize
public int getResultSize()Description copied from interface:FullTextQueryReturns the number of hits for this search Caution: The number of results might be slightly different fromgetResultList().size()because getResultList() may be not in sync with the database at the time of query.- Specified by:
getResultSizein interfaceFullTextQuery
-
setCriteriaQuery
Description copied from interface:FullTextQueryDefines 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:
setCriteriaQueryin interfaceFullTextQuery
-
setProjection
Description copied from interface:FullTextQueryDefines 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 aTwoWayFieldBridgeUnless 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:
setProjectionin interfaceFullTextQuery
-
enableFullTextFilter
Description copied from interface:FullTextQueryEnable a given filter by its name. Returns a FullTextFilter object that allows filter parameter injection- Specified by:
enableFullTextFilterin interfaceFullTextQuery
-
disableFullTextFilter
Description copied from interface:FullTextQueryDisable a given filter by its name- Specified by:
disableFullTextFilterin interfaceFullTextQuery
-
setResultTransformer
Description copied from interface:FullTextQuerydefines a result transformer used during projection- Specified by:
setResultTransformerin interfaceFullTextQuery
-
getResultList
- Specified by:
getResultListin interfacejavax.persistence.Query
-
getFacetManager
- Specified by:
getFacetManagerin interfaceFullTextQuery- Returns:
- return the manager for all faceting related operations
-
wrapLockException
public javax.persistence.PersistenceException wrapLockException(org.hibernate.HibernateException e, org.hibernate.LockOptions lockOptions) -
getSingleResult
- Specified by:
getSingleResultin interfacejavax.persistence.Query
-
setMaxResults
- Specified by:
setMaxResultsin interfacejavax.persistence.Query
-
getMaxResults
public int getMaxResults()- Specified by:
getMaxResultsin interfacejavax.persistence.Query
-
setFirstResult
- Specified by:
setFirstResultin interfacejavax.persistence.Query
-
getFirstResult
public int getFirstResult()- Specified by:
getFirstResultin interfacejavax.persistence.Query
-
explain
Description copied from interface:FullTextQueryReturn the LuceneExplanationobject describing the score computation for the matching object/document in the current query- Specified by:
explainin interfaceFullTextQuery- Parameters:
documentId- Lucene Document id to be explain. This is NOT the object id- Returns:
- Lucene Explanation
-
limitExecutionTimeTo
Description copied from interface:FullTextQuery*Experimental* API, subject to change or removal Limit the time used by Hibernate Search to execute the query. When the limit is reached, results already fetched are returned. This time limit is a best effort. The query will likely run for longer than the provided time. The time limit only applies to the interactions between Hibernate Search and Lucene. In other words, a query to the database will not be limited. If the limit is reached and all results are not yet fetched,FullTextQuery.hasPartialResults()returns true.- Specified by:
limitExecutionTimeToin interfaceFullTextQuery- Parameters:
timeout- time out periodtimeUnit- time out unit
-
hasPartialResults
public boolean hasPartialResults()Description copied from interface:FullTextQuery*Experimental* API, subject to change or removal When usingFullTextQuery.limitExecutionTimeTo(long, java.util.concurrent.TimeUnit)}, returns true if partial results are returned (ie if the time limit has been reached and the result fetching process has been terminated.- Specified by:
hasPartialResultsin interfaceFullTextQuery
-
initializeObjectsWith
public FullTextQuery initializeObjectsWith(ObjectLookupMethod lookupMethod, DatabaseRetrievalMethod retrievalMethod) Description copied from interface:FullTextQueryRefine the strategies used to load entities. The lookup method defines whether or not to lookup first in the second level cache or the persistence context before trying to initialize objects from the database. Defaults to SKIP. The database retrieval method defines how objects are loaded from the database. Defaults to QUERY. Note that Hibernate Search can deviate from these choices when it makes sense.- Specified by:
initializeObjectsWithin interfaceFullTextQuery
-
executeUpdate
public int executeUpdate()- Specified by:
executeUpdatein interfacejavax.persistence.Query
-
setHint
- Specified by:
setHintin interfacejavax.persistence.Query
-
getHints
- Specified by:
getHintsin interfacejavax.persistence.Query
-
setParameter
- Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(javax.persistence.Parameter<Calendar> calendarParameter, Calendar calendar, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(javax.persistence.Parameter<Date> dateParameter, Date date, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
- Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(String name, Date value, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(String name, Calendar value, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
- Specified by:
setParameterin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(int position, Date value, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
getParameters
- Specified by:
getParametersin interfacejavax.persistence.Query
-
setParameter
public javax.persistence.Query setParameter(int position, Calendar value, javax.persistence.TemporalType temporalType) - Specified by:
setParameterin interfacejavax.persistence.Query
-
getParameter
- Specified by:
getParameterin interfacejavax.persistence.Query
-
getParameter
- Specified by:
getParameterin interfacejavax.persistence.Query
-
getParameter
- Specified by:
getParameterin interfacejavax.persistence.Query
-
getParameter
- Specified by:
getParameterin interfacejavax.persistence.Query
-
isBound
- Specified by:
isBoundin interfacejavax.persistence.Query
-
getParameterValue
- Specified by:
getParameterValuein interfacejavax.persistence.Query
-
getParameterValue
- Specified by:
getParameterValuein interfacejavax.persistence.Query
-
getParameterValue
- Specified by:
getParameterValuein interfacejavax.persistence.Query
-
setFlushMode
- Specified by:
setFlushModein interfacejavax.persistence.Query
-
getFlushMode
- Specified by:
getFlushModein interfacejavax.persistence.Query
-
setLockMode
- Specified by:
setLockModein interfacejavax.persistence.Query
-
getLockMode
- Specified by:
getLockModein interfacejavax.persistence.Query
-
unwrap
- Specified by:
unwrapin interfacejavax.persistence.Query
-