Annotation Type ObjectProjection


@Documented @Target(PARAMETER) @Retention(RUNTIME) @MethodParameterMapping(processor=@MethodParameterMappingAnnotationProcessorRef(type=org.hibernate.search.mapper.pojo.mapping.definition.annotation.processing.impl.ObjectProjectionProcessor.class,retrieval=CONSTRUCTOR)) public @interface ObjectProjection
Maps a constructor parameter to an object projection bound to a specific object field in the indexed document.

The content of the object projection is defined in the constructor parameter type by another ProjectionConstructor.

Compared to the basic composite projection, an object projection is bound to a specific object field, and thus it yields zero, one or many values, as many as there are objects in the targeted object field. Therefore, you must take care of using a List<...> as your constructor parameter type if the object field is multi-valued.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The paths of nested index field to be excluded, i.e.
    int
    The number of levels of object projections that will have all their nested field/object projections included by default and actually be retrieved from the index (projections on excluded fields will be ignored and will have their value set to null, or an empty collection for multi-valued fields).
    The paths of nested index field to be included, i.e.
     
  • Element Details

    • path

      String path
      Returns:
      The path to the object field whose object(s) will be extracted. Defaults to the name of the annotated constructor parameter, if it can be retrieved (requires the class to be compiled with the -parameters flag; otherwise an empty path will lead to a failure).
      See Also:
      Default:
      ""
    • includePaths

      String[] includePaths
      The paths of nested index field to be included, i.e. for which the corresponding nested projections will actually be retrieved from the index (projections on excluded fields will be ignored and will have their value set to null, or an empty collection for multi-valued fields).

      This takes precedence over includeDepth().

      Cannot be used when excludePaths() contains any paths.

      By default, if none of includePaths, excludePaths() or includeDepth() are defined, all index fields are included.

      Returns:
      The paths of index fields to include explicitly. Provided paths must be relative to the projected object field, i.e. they must not include the path().
      Default:
      {}
    • excludePaths

      @Incubating String[] excludePaths
      The paths of nested index field to be excluded, i.e. for which the corresponding nested projections will not be retrieved from the index and will instead have their value set to null, or an empty collection for multi-valued fields.

      This takes precedence over includeDepth().

      Cannot be used when includePaths() contains any paths.

      By default, if none of includePaths(), excludePaths or includeDepth() are defined, all index fields are included.

      Index fields that are represented in object projections but are excluded through filters (includePaths()/excludePaths()/includeDepth()) will not be retrieved from the index and will have their value set to null, or an empty collection for multi-valued fields.

      Returns:
      The paths of index fields to exclude explicitly. Provided paths must be relative to the object projection, i.e. they must not include the path().
      Default:
      {}
    • includeDepth

      int includeDepth
      The number of levels of object projections that will have all their nested field/object projections included by default and actually be retrieved from the index (projections on excluded fields will be ignored and will have their value set to null, or an empty collection for multi-valued fields).

      Up to and including that depth, object projections will be included along with their nested (non-object) field projections, even if these fields are not included explicitly through includePaths, unless these fields are excluded explicitly through excludePaths:

      • includeDepth=0 means fields of this object projection are not included, nor is any field of nested object projections, unless these fields are included explicitly through includePaths().
      • includeDepth=1 means fields of this object projection are included, unless these fields are explicitly excluded through excludePaths, but not fields of nested object projections (@ObjectProjection within this @ObjectProjection), unless these fields are included explicitly through includePaths().
      • includeDepth=2 means fields of this object projection are included, and so are fields of immediately nested object projections (@ObjectProjection within this @ObjectProjection), unless these fields are explicitly excluded through excludePaths, but not fields of nested object projections beyond that (@ObjectProjection within an @ObjectProjection within this @ObjectProjection), unless these fields are included explicitly through includePaths().
      • And so on.
      The default value depends on the value of includePaths() attribute:
      • if includePaths() is empty, the default is Integer.MAX_VALUE (include all fields at every level)
      • if includePaths() is not empty, the default is 0 (only include fields included explicitly).
      Returns:
      The number of levels of object projections that will have all their fields included by default.
      Default:
      -1