You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/migration/index.adoc
+3
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,9 @@ interfaces are removed in this version. They have their alternatives in a `org.h
99
99
Instead, we are introducing the `org.hibernate.search.mapper.pojo.massindexing.MassIndexingTypeGroupMonitor`
100
100
that can be obtained through `org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor#typeGroupMonitor(..)`.
101
101
This new type group monitor has more flexibility and also allows implementors to skip total count computations if needed.
102
+
- `multi()` methods exposed in various projection DSL steps are deprecated in favour of an `accumulator(ProjectionAccumulator.Provider)`.
103
+
Check the `ProjectionAccumulator` factory methods to see the list of built-in accumulators that provide support for nullable/optional single-valued projections
104
+
and for multivalued ones such as lists, sets arrays and more.
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/public/reference/_mapping-projection.adoc
+15-6
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ See <<mapping-projection-inner-inference>> for more information on how construct
39
39
+
40
40
Alternatively, the field projection can be configured explicitly with <<search-dsl-projection-field-mapping,`@FieldProjection`>>.
41
41
<4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type.
42
-
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as a `List<...>`>> or supertype.
42
+
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as one of the multivalued containers available in `ProjectionAccumulator`>> or their supertype.
43
43
+
44
44
Alternatively, the object projection can be configured explicitly with <<search-dsl-projection-object-mapping,`@ObjectProjection`>>.
45
45
<5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well.
@@ -106,18 +106,27 @@ for the target field, which in general is the type of the property annotated wit
106
106
(generally mapped using <<mapping-indexedembedded,`@IndexedEmbedded`>>),
107
107
set the parameter type to another custom type annotated with `@ProjectionConstructor`,
108
108
whose constructor will define which fields to extract from that object field.
109
-
* For a multivalued projection, follow the rules above then wrap the type with `Iterable`, `Collection` or `List`,
110
-
e.g. `Iterable<SomeType>`, `Collection<SomeType>` or `List<SomeType>`.
109
+
* For projections where values are wrapped in some container, be it a multivalued projection represented by some collection or array,
110
+
or a single-valued projection wrapped in an optional,
111
+
follow the rules above for the elements inside the container and then wrap the type with one of the containers
112
+
available in `ProjectionAccumulator` (`Iterable`, `Collection`, `List`, etc.),
113
+
e.g. `Iterable<SomeType>`, `Collection<SomeType>`, `List<SomeType>`, etc.
111
114
112
115
[IMPORTANT]
113
116
====
114
117
Constructor parameters meant to represent a multivalued projection
115
-
can **only** have the type `Iterable<...>`, `Collection<...>` or `List<...>`.
118
+
**must** have the type of one of the supported multivalued containers.
119
+
====
116
120
117
-
Other container types such as `Map` or `Optional` are not supported
118
-
https://hibernate.atlassian.net/browse/HSEARCH-4577[at the moment].
121
+
[NOTE]
122
+
====
123
+
In case the `ProjectionAccumulator` does not provide a suitable accumulator for a container/collection
124
+
needed for a constructor parameter mapping, <<binding-projection-multi,a custom projection binding>> can be implemented
125
+
and a user-implemented projection accumulator applied.
119
126
====
120
127
128
+
129
+
121
130
[[mapping-projection-inner-inference-fieldpath]]
122
131
=== [[mapper-orm-mapping-projection-inner-inference-fieldpath]] Inner projection and field path
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/public/reference/_search-dsl-projection.adoc
+6-6
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ See <<mapping-projection-inner-inference>> for more information on how construct
72
72
+
73
73
Alternatively, the field projection can be configured explicitly with <<search-dsl-projection-field-mapping,`@FieldProjection`>>.
74
74
<4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type.
75
-
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as a `List<...>`>> or supertype.
75
+
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as one of the multivalued containers available in `ProjectionAccumulator`>> or their supertype.
76
76
+
77
77
Alternatively, the object projection can be configured explicitly with <<search-dsl-projection-object-mapping,`@ObjectProjection`>>.
78
78
<5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well.
To return multiple values, and thus allow projection on multivalued fields, use `.multi()`.
614
-
This will change the return type of the projection to `List<Double>`.
613
+
To return multiple values, and thus allow projection on multivalued fields, use `.accumulator(..)`.
614
+
This will change the return type of the projection to `SomeContainer<Double>`.
615
615
616
616
.Returning the distance to a point, for multivalued fields
617
617
====
@@ -834,7 +834,7 @@ See <<mapping-projection-inner-inference>> for more information on how construct
834
834
+
835
835
Alternatively, the field projection can be configured explicitly with <<search-dsl-projection-field-mapping,`@FieldProjection`>>.
836
836
<4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type.
837
-
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as a `List<...>`>> or supertype.
837
+
Multivalued projections <<mapping-projection-inner-inference-type,must be modeled as one of the multivalued containers available in `ProjectionAccumulator`>> or their supertype.
838
838
+
839
839
Alternatively, the object projection can be configured explicitly with <<search-dsl-projection-object-mapping,`@ObjectProjection`>>.
840
840
<5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well.
Copy file name to clipboardExpand all lines: engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulatorProviderFactory.java
Copy file name to clipboardExpand all lines: mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/logging/impl/Log.java
+1-2
Original file line number
Diff line number
Diff line change
@@ -1050,8 +1050,7 @@ void indexingProgressWithRemainingTime(float estimatePercentileComplete, long do
1050
1050
1051
1051
@Message(id = ID_OFFSET + 170,
1052
1052
value = "Implicit binding of a java.util.SortedSet<%1$s> constructor parameter is not possible since %1$s is not implementing java.lang.Comparable."
1053
-
+ " Either make %1$s implement java.lang.Comparable or use a programmatic mapping and provide"
1054
-
+ " a custom ProjectionAccumulatorProviderFactory that, for example, utilizes a ProjectionAccumulator.sortedSet(comparator) accumulator provider.")
1053
+
+ " Either make %1$s implement java.lang.Comparable or create a custom @ProjectionBinding and use the ProjectionAccumulator.sortedSet(comparator) accumulator provider in it.")
Copy file name to clipboardExpand all lines: mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/ProjectionBindingContext.java
Copy file name to clipboardExpand all lines: mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/impl/ProjectionBindingContextImpl.java
0 commit comments