Annotation Type ObjectProjection
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 ElementsModifier and TypeOptional ElementDescriptionString[]
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 tonull
, or an empty collection for multi-valued fields.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 tonull
, or an empty collection for multi-valued fields).String[]
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 tonull
, or an empty collection for multi-valued fields).
-
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 emptypath
will lead to a failure). - See Also:
- Default:
""
-
includePaths
String[] includePathsThe 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 tonull
, 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()
orincludeDepth()
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
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 tonull
, 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
orincludeDepth()
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 tonull
, 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 includeDepthThe 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 tonull
, 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 throughexcludePaths
: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 throughincludePaths()
.includeDepth=1
means fields of this object projection are included, unless these fields are explicitly excluded throughexcludePaths
, but not fields of nested object projections (@ObjectProjection
within this@ObjectProjection
), unless these fields are included explicitly throughincludePaths()
.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 throughexcludePaths
, but not fields of nested object projections beyond that (@ObjectProjection
within an@ObjectProjection
within this@ObjectProjection
), unless these fields are included explicitly throughincludePaths()
.- And so on.
includePaths()
attribute:- if
includePaths()
is empty, the default isInteger.MAX_VALUE
(include all fields at every level) - if
includePaths()
is not empty, the default is0
(only include fields included explicitly).
- Returns:
- The number of levels of object projections that will have all their fields included by default.
- Default:
-1
-