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
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
Steps to Reproduce
Migrating from 2.2.x to 2.4.x and we are now getting a compilation error related to custom queries that don't relate to a root entity. We have a number of repository methods that are effectively just queries, taking arguments to map to named parameters that don't relate directly to the root entity. This is a super useful way of defining the SQL in the @Query annotation and avoiding boilerplate. This used to work in 2.2.x but now fails in 2.4.x. Query is as such:
...
@Query(
"INSERT INTO object_group(key_id, group_id) VALUES ( :keyId, :groupId) "
+ "ON CONFLICT(key_id, group_id) DO NOTHING")
protected abstract void updateObjectGroupMembershipByKeyIdAndGroupId(
Long keyId, Long groupId);
...
The error is:
Argument [role] cannot be null
java.lang.IllegalArgumentException: Argument [role] cannot be null
Which relates to a field in the root entity of the repository. It appears our arguments are trying to be processed as fields within the root entity, rather than just being mapped to arbitrary named parameters in the SQL like they used to be. I imagine this might be a new feature/behaviour introduced since 2.2.x? Is there a way to turn this off? for it to just map argument -> sql parameter and execute the thing without trying to relate it back to the root entity? Its almost like I want to be able to write a @Query without a GenericRepository (that defines the root entity).
Can make test repo if useful.
Micronaut Version: 2.5.1
Micronaut Data Version: 2.4.2
The text was updated successfully, but these errors were encountered:
Task List
Steps to Reproduce
Migrating from 2.2.x to 2.4.x and we are now getting a compilation error related to custom queries that don't relate to a root entity. We have a number of repository methods that are effectively just queries, taking arguments to map to named parameters that don't relate directly to the root entity. This is a super useful way of defining the SQL in the
@Query
annotation and avoiding boilerplate. This used to work in 2.2.x but now fails in 2.4.x. Query is as such:The error is:
Which relates to a field in the root entity of the repository. It appears our arguments are trying to be processed as fields within the root entity, rather than just being mapped to arbitrary named parameters in the SQL like they used to be. I imagine this might be a new feature/behaviour introduced since 2.2.x? Is there a way to turn this off? for it to just map argument -> sql parameter and execute the thing without trying to relate it back to the root entity? Its almost like I want to be able to write a
@Query
without a GenericRepository (that defines the root entity).Can make test repo if useful.
The text was updated successfully, but these errors were encountered: