Class ToManySelectionPathHandler
java.lang.Object
ch.tocco.nice2.persist.core.impl.hibernate.query.selection.AbstractToManySelectionPathHandler
ch.tocco.nice2.persist.core.impl.hibernate.query.selection.ToManySelectionPathHandler
- All Implemented Interfaces:
SelectionPathHandler
SelectionPathHandler
for all to-many fields (except binaries).
This handler does not add anything to the query directly - to-many paths would return multiple rows per result, which would
cause issues with pagination.
Instead, an additional query is executed to fetch all the to-many values for the results of the primary query.
One query is executed per 'path-group' (all fields that belong to the same path).-
Nested Class Summary
Nested classes/interfaces inherited from class ch.tocco.nice2.persist.core.impl.hibernate.query.selection.AbstractToManySelectionPathHandler
AbstractToManySelectionPathHandler.QueryHolder
-
Field Summary
Fields inherited from class ch.tocco.nice2.persist.core.impl.hibernate.query.selection.AbstractToManySelectionPathHandler
criteriaBuilder, dataModel, fieldResolver, interceptors, parameterProviders, paths, predicateFactory, queries, rootKeyName, rootModel, selectionInterceptorMap, session, typeManager
-
Constructor Summary
ConstructorDescriptionToManySelectionPathHandler
(DataModel dataModel, TypeManager typeManager, FieldResolver fieldResolver, EntityModel rootModel, PredicateFactory predicateFactory, List<QueryBuilderInterceptor> interceptors, Map<String, ParameterProvider<?>> parameterProviders, org.hibernate.Session session, CriteriaBuilderWrapper criteriaBuilder) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
processAdditionalQuery
(AbstractToManySelectionPathHandler.QueryHolder queryHolder, List<Path> paths) <RT> void
processResults
(List<Object[]> queryResults, List<RT> target, SelectionRegistry selectionRegistry, ResultRowMapper<RT> mapper) This is called after the query was executed.void
boolean
All to-many fields except binaries are supported.Methods inherited from class ch.tocco.nice2.persist.core.impl.hibernate.query.selection.AbstractToManySelectionPathHandler
doLoadData, extractAllRootPrimaryKeys, processSelection
-
Constructor Details
-
ToManySelectionPathHandler
public ToManySelectionPathHandler(DataModel dataModel, TypeManager typeManager, FieldResolver fieldResolver, EntityModel rootModel, PredicateFactory predicateFactory, List<QueryBuilderInterceptor> interceptors, Map<String, ParameterProvider<?>> parameterProviders, org.hibernate.Session session, CriteriaBuilderWrapper criteriaBuilder)
-
-
Method Details
-
supports
All to-many fields except binaries are supported.- Returns:
- true if this instance supports the given path.
-
select
- Parameters:
path
- a path that should be selected by this handler.
-
processAdditionalQuery
protected void processAdditionalQuery(AbstractToManySelectionPathHandler.QueryHolder queryHolder, List<Path> paths) - Specified by:
processAdditionalQuery
in classAbstractToManySelectionPathHandler
-
processResults
public <RT> void processResults(List<Object[]> queryResults, List<RT> target, SelectionRegistry selectionRegistry, ResultRowMapper<RT> mapper) Description copied from interface:SelectionPathHandler
This is called after the query was executed. The handler is expected to map the query results to the target array that is returned from the query builder.- Parameters:
queryResults
- the query result, contains all paths added duringSelectionPathHandler.processSelection(SelectionRegistry)
target
- the list of arrays that will be returned from the query builder
-