Class DelegatingSearchSession
- java.lang.Object
-
- org.hibernate.search.mapper.orm.session.impl.DelegatingSearchSession
-
- All Implemented Interfaces:
SearchSession
public class DelegatingSearchSession extends Object implements SearchSession
A lazily initializingSearchSession.This implementation allows to call
Search.session(Session)before Hibernate Search is fully initialized, which can be useful in CDI/Spring environments.
-
-
Constructor Summary
Constructors Constructor Description DelegatingSearchSession(Supplier<? extends HibernateOrmSearchSessionMappingContext> mappingContextProvider, org.hibernate.Session session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidautomaticIndexingSynchronizationStrategy(AutomaticIndexingSynchronizationStrategy synchronizationStrategy)Set theAutomaticIndexingSynchronizationStrategyto use for this session.SearchIndexingPlanindexingPlan()voidindexingPlanFilter(SearchIndexingPlanFilter filter)Set a filter configuration and define which types must be included/excluded when indexed within indexing plans of the current session (either automatically or manually).voidindexingPlanSynchronizationStrategy(IndexingPlanSynchronizationStrategy synchronizationStrategy)Set theIndexingPlanSynchronizationStrategyto use for this session.MassIndexermassIndexer(Collection<? extends Class<?>> types)Creates aMassIndexerto rebuild the indexes mapped to the given types, or to any of their sub-types.SearchSchemaManagerschemaManager(Collection<? extends Class<?>> types)Create aSearchSchemaManagerfor the indexes mapped to the given types, or to any of their sub-types.<T> SearchScope<T>scope(Class<T> expectedSuperType, Collection<String> entityNames)Create aSearchScopelimited to entity types referenced by their name.<T> SearchScope<T>scope(Collection<? extends Class<? extends T>> types)Create aSearchScopelimited to the given types.<T> SearchQuerySelectStep<?,EntityReference,T,SearchLoadingOptionsStep,?,?>search(Collection<? extends Class<? extends T>> types)Initiate the building of a search query.<T> SearchQuerySelectStep<?,EntityReference,T,SearchLoadingOptionsStep,?,?>search(SearchScope<T> scope)Initiate the building of a search query.EntityManagertoEntityManager()org.hibernate.SessiontoOrmSession()SearchWorkspaceworkspace(Collection<? extends Class<?>> types)Create aSearchWorkspacefor the indexes mapped to the given types, or to any of their sub-types.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.search.mapper.orm.session.SearchSession
massIndexer, massIndexer, schemaManager, schemaManager, scope, scope, search, workspace, workspace
-
-
-
-
Constructor Detail
-
DelegatingSearchSession
public DelegatingSearchSession(Supplier<? extends HibernateOrmSearchSessionMappingContext> mappingContextProvider, org.hibernate.Session session)
-
-
Method Detail
-
search
public <T> SearchQuerySelectStep<?,EntityReference,T,SearchLoadingOptionsStep,?,?> search(Collection<? extends Class<? extends T>> types)
Description copied from interface:SearchSessionInitiate the building of a search query.The query will target the indexes mapped to the given types, or to any of their sub-types.
- Specified by:
searchin interfaceSearchSession- Type Parameters:
T- A supertype of all indexed types that will be targeted by the search query.- Parameters:
types- A collection of indexed types, or supertypes of all indexed types that will be targeted by the search query.- Returns:
- The initial step of a DSL where the search query can be defined.
- See Also:
SearchQuerySelectStep
-
search
public <T> SearchQuerySelectStep<?,EntityReference,T,SearchLoadingOptionsStep,?,?> search(SearchScope<T> scope)
Description copied from interface:SearchSessionInitiate the building of a search query.The query will target the indexes in the given scope.
- Specified by:
searchin interfaceSearchSession- Type Parameters:
T- A supertype of all types in the given scope.- Parameters:
scope- A scope representing all indexed types that will be targeted by the search query.- Returns:
- The initial step of a DSL where the search query can be defined.
- See Also:
SearchQuerySelectStep
-
schemaManager
public SearchSchemaManager schemaManager(Collection<? extends Class<?>> types)
Description copied from interface:SearchSessionCreate aSearchSchemaManagerfor the indexes mapped to the given types, or to any of their sub-types.- Specified by:
schemaManagerin interfaceSearchSession- Parameters:
types- A collection of indexed types, or supertypes of all indexed types that will be targeted by the schema manager.- Returns:
- A
SearchSchemaManager.
-
workspace
public SearchWorkspace workspace(Collection<? extends Class<?>> types)
Description copied from interface:SearchSessionCreate aSearchWorkspacefor the indexes mapped to the given types, or to any of their sub-types.- Specified by:
workspacein interfaceSearchSession- Parameters:
types- A collection of indexed types, or supertypes of all indexed types that will be targeted by the workspace.- Returns:
- A
SearchWorkspace.
-
massIndexer
public MassIndexer massIndexer(Collection<? extends Class<?>> types)
Description copied from interface:SearchSessionCreates aMassIndexerto rebuild the indexes mapped to the given types, or to any of their sub-types.- Specified by:
massIndexerin interfaceSearchSession- Parameters:
types- A collection of indexed types, or supertypes of all indexed types that will be targeted by the workspace.- Returns:
- A
SearchWorkspace.
-
scope
public <T> SearchScope<T> scope(Collection<? extends Class<? extends T>> types)
Description copied from interface:SearchSessionCreate aSearchScopelimited to the given types.- Specified by:
scopein interfaceSearchSession- Type Parameters:
T- A supertype of all types to include in the scope.- Parameters:
types- A collection of types to include in the scope.- Returns:
- The created scope.
- See Also:
SearchScope
-
scope
public <T> SearchScope<T> scope(Class<T> expectedSuperType, Collection<String> entityNames)
Description copied from interface:SearchSessionCreate aSearchScopelimited to entity types referenced by their name.- Specified by:
scopein interfaceSearchSession- Type Parameters:
T- A supertype of all entity types to include in the scope.- Parameters:
expectedSuperType- A supertype of all entity types to include in the scope.entityNames- A collection of entity names. SeeEntity.name().- Returns:
- The created scope.
- See Also:
SearchScope
-
toEntityManager
public EntityManager toEntityManager()
- Specified by:
toEntityManagerin interfaceSearchSession- Returns:
- The underlying
EntityManagerused by thisSearchSession.
-
toOrmSession
public org.hibernate.Session toOrmSession()
- Specified by:
toOrmSessionin interfaceSearchSession- Returns:
- The underlying
Sessionused by thisSearchSession.
-
indexingPlan
public SearchIndexingPlan indexingPlan()
- Specified by:
indexingPlanin interfaceSearchSession- Returns:
- The indexing plan for this session, allowing to explicitly index entities or delete them from the index, or to process entity changes or even write to the indexes before the transaction is committed.
-
automaticIndexingSynchronizationStrategy
public void automaticIndexingSynchronizationStrategy(AutomaticIndexingSynchronizationStrategy synchronizationStrategy)
Description copied from interface:SearchSessionSet theAutomaticIndexingSynchronizationStrategyto use for this session.Behavior is undefined if called while entity changes are pending: be sure to call this only just after creating a session, or just after committing a transaction.
- Specified by:
automaticIndexingSynchronizationStrategyin interfaceSearchSession- Parameters:
synchronizationStrategy- The synchronization strategy to use- See Also:
AutomaticIndexingSynchronizationStrategy
-
indexingPlanSynchronizationStrategy
public void indexingPlanSynchronizationStrategy(IndexingPlanSynchronizationStrategy synchronizationStrategy)
Description copied from interface:SearchSessionSet theIndexingPlanSynchronizationStrategyto use for this session.Behavior is undefined if called while entity changes are pending: be sure to call this only just after creating a session, or just after committing a transaction.
- Specified by:
indexingPlanSynchronizationStrategyin interfaceSearchSession- Parameters:
synchronizationStrategy- The synchronization strategy to use- See Also:
IndexingPlanSynchronizationStrategy
-
indexingPlanFilter
public void indexingPlanFilter(SearchIndexingPlanFilter filter)
Description copied from interface:SearchSessionSet a filter configuration and define which types must be included/excluded when indexed within indexing plans of the current session (either automatically or manually).This does not affect indexing that does not rely on indexing plans, like the mass indexer.
If a type is not explicitly included/excluded directly or through an included/excluded supertype, the decision will be made by
an application filter, which defaults to including all types.- Specified by:
indexingPlanFilterin interfaceSearchSession- Parameters:
filter- The filter that includes/excludes types when indexed.
-
-