Panache Query/DTO projection with fields from referenced entity

553 views
Skip to first unread message

Marco Rizzi

unread,
Feb 21, 2021, 10:13:08 AM2/21/21
to Quarkus Development mailing list
Hi all,
currently, the Panache projection works great if the parameters in the DTO's constructor belongs to the same entity.

The case of having a DTO with also fields from referenced entities is not working because the required "dot" notation to build a working query is not compatible with Java naming that doesn't allow the usage of dots `.` in a parameter's name.

My proposal is to add a `ProjectionForField` annotation for `ElementType.PARAMETER` to let the developers provide the "SQL path" to get the value for the field the annotation refers to in the DTO's constructor, considering the projection works starting from the DTO's constructor parameters.

The annotation's name `ProjectionForField` wants to be consistent with the annotation `ProjectionFor` (available for Panache Mongo extension) that refers to classes.

I've opened an issue to provide sample code to help clarify the proposal [1] with also a related PR [2].

Cheers,
Marco


Reply all
Reply to author
Forward
0 new messages