Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate Search (
https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiYzkxNmFm...
) / New Feature (
https://hibernate.atlassian.net/browse/HSEARCH-4574?atlOrigin=eyJpIjoiYzk...
) HSEARCH-4574 (
https://hibernate.atlassian.net/browse/HSEARCH-4574?atlOrigin=eyJpIjoiYzk...
) Explicit binding of constructor parameters for @ProjectionConstructor (
https://hibernate.atlassian.net/browse/HSEARCH-4574?atlOrigin=eyJpIjoiYzk...
)
Change By: Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Follows up on
[
https://hibernate.atlassian.net/browse/HSEARCH-3927|https://hibernate.atl...].
Use case: define a parameter of a projection constructor as a specific inner projection
either something completely different from field projections such as an identifier
projection, or more precise configuration of field value/object projections.
For example:
{code:java}@ProjectionConstructor
record MyProjection(@IdProjection String id, @FieldProjection(convert = ValueConvert.NO)
String myEnum){code}
Currently, all constructor parameters are bound implicitly, which limits users to field
projections or object projections. There is no ID projection in particular, which prevents
from fully loading an entity through its projection constructor, since it can’t project on
the ID. This also means {{-parameters}} _must_ be passed to the compiler when compiling
projection constructors.
Core set of annotations (must be implemented):
* {{@IdProjection}}
* {{@FieldProjection}}
* {{@ObjectProjection}}
** we might want a {{includeDepth}} in here,
* {{@ProjectionBinding(binder = ...)}} (for custom projection annotations)
Less useful/more challenging annotations that could be split into another ticket:
* {{@ScoreProjection}}
* {{@DistanceProjection}} (=> moved to
[
https://hibernate.atlassian.net/browse/HSEARCH-4807|https://hibernate.atl...]
)
* {{@EntityProjection}}
* {{@EntityReferenceProjection}}
* {{@DocumentReferenceProjection}}
* Others, see all projections available.
Some things to test in particular:
* There should be no error if {{-parameters}} is not used when compiling, as long as all
constructor parameters of a projection constructor have a {{@*Projection}} annotation (and
that projection specifies the field path, if relevant).
* There should be an error if {{-parameters}} is not used when compiling, and all
constructor parameters of a projection constructor have a {{@*Projection}} annotation, but
one of them is annotated with {{@FieldProjection}} or {{@ObjectProjection}} and does not
specify the field path.
* There should be an error when using two {{@*Projection}} annotations on the same
constructor parameter.
* And more (the list above is not exhaustive, obviously).
(
https://hibernate.atlassian.net/browse/HSEARCH-4574#add-comment?atlOrigin...
) Add Comment (
https://hibernate.atlassian.net/browse/HSEARCH-4574#add-comment?atlOrigin...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )