Class SelectionRegistry
java.lang.Object
ch.tocco.nice2.persist.core.impl.hibernate.query.selection.SelectionRegistry
A registry for a
CustomSelection
which tracks the following two things:
- at which position the user expects the paths that were added through CustomSelection.addPath(String...)
. These
are the results that will be returned from the CriteriaQueryBuilder
and may contain to-many paths
- the position of paths that are actually part of the main query. This is not equal to the paths requested by the user,
as for example to-many paths are evaluated separately (see SelectionPathHandler
implementations) and some additional
data is queried as well in order to check access security.
This class also makes sure that no path is queried twice. If it is required by multiple paths, it will be only queried once
and then mapped to the correct index.-
Constructor Summary
ConstructorDescriptionSelectionRegistry
(FieldResolver fieldResolver, jakarta.persistence.criteria.Root<?> queryRoot, org.hibernate.Session session, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, ParameterCollector parameterCollector) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addQueryPath
(Path path) Add a path to the selection of the main query; these paths will be available in the temporary resultvoid
addResultPath
(Path path, int index) Add a path (and its position in the array) that should be returned from theCriteriaQueryBuilderImpl
protected jakarta.persistence.criteria.From
<?, ?> findSelectionRoot
(String path, jakarta.persistence.criteria.Root<?> queryRoot, ParameterCollector parameterCollector) Finds theJoin
(orRoot
) instance that is represented by the given path (the last path element).int
boolean
hasQueryPath
(Path path) int
indexOfQueryPath
(Path path) int
indexOfResultPath
(Path path) int
void
setToManyPathResultLimit
(int limit) jakarta.persistence.criteria.Selection
<Object[]>
-
Constructor Details
-
SelectionRegistry
public SelectionRegistry(FieldResolver fieldResolver, jakarta.persistence.criteria.Root<?> queryRoot, org.hibernate.Session session, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, ParameterCollector parameterCollector)
-
-
Method Details
-
addResultPath
Add a path (and its position in the array) that should be returned from theCriteriaQueryBuilderImpl
-
indexOfResultPath
- Returns:
- position of a given result path in the result array
-
numberOfResultPaths
public int numberOfResultPaths()- Returns:
- number of selected result paths (i.e the size of the resulting array per row)
-
addQueryPath
Add a path to the selection of the main query; these paths will be available in the temporary result -
hasQueryPath
-
indexOfQueryPath
- Returns:
- position of a given query path in the temporary result
-
toSelection
- Returns:
- a
Selection
instance that contains all the query paths contained in this registry
-
findSelectionRoot
protected jakarta.persistence.criteria.From<?,?> findSelectionRoot(String path, jakarta.persistence.criteria.Root<?> queryRoot, ParameterCollector parameterCollector) Finds theJoin
(orRoot
) instance that is represented by the given path (the last path element). An empty string represents the query root. Note: the path may not contain a field at the end (fields are handled by the subclasses)! -
getToManyPathResultLimit
public int getToManyPathResultLimit() -
setToManyPathResultLimit
public void setToManyPathResultLimit(int limit)
-