public class SelectionRegistry extends Object
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 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

      public void addResultPath(Path path, int index)
      Add a path (and its position in the array) that should be returned from the CriteriaQueryBuilderImpl
    • indexOfResultPath

      public int indexOfResultPath(Path path)
      position of a given result path in the result array
    • numberOfResultPaths

      public int numberOfResultPaths()
      number of selected result paths (i.e the size of the resulting array per row)
    • addQueryPath

      public void addQueryPath(Path path)
      Add a path to the selection of the main query; these paths will be available in the temporary result
    • hasQueryPath

      public boolean hasQueryPath(Path path)
    • indexOfQueryPath

      public int indexOfQueryPath(Path path)
      position of a given query path in the temporary result
    • toSelection

      public jakarta.persistence.criteria.Selection<Object[]> toSelection()
      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 the Join (or Root) 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)