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
I'm currently porting a system that uses Spring Data JPA to Micronaut using Hibernate Reactive, and I have the following entities:
@Entity
@Data
public class UserGroupMembership {
@Id
private Long uid;
@ManyToOne(fetch = FetchType.EAGER)
private UserGroup userGroup;
@ManyToOne(fetch = FetchType.EAGER)
private User user;
}
@Entity
@Data
public class UserGroup {
@Id
private Long uid;
@OneToMany(mappedBy="userGroup", fetch = FetchType.LAZY)
private Set<UserGroupMembership> userAuthorizations = new HashSet<UserGroupMembership>();
@ManyToOne
private Area area;
}
@Entity
@Data
public class Area {
@Id
private Long uid;
@ManyToOne
private Area parent;
@ManyToOne(fetch = FetchType.LAZY)
private ApplicationEnvironment applicationEnvironment;
}
And the repository:
@Repository
public interface UserGroupMembershipRepository extends ReactiveStreamsCrudRepository<UserGroupMembership, Long> {
Flux<UserGroupMembership> findAllByUserLogin(String login);
@Join(value = "userGroup.area", type = Join.Type.FETCH)
Flux<UserGroupMembership> findAllByUserLoginAndUserGroupAreaUid(String login, Long uid);
}
The method findAllByUserLoginAndUserGroupAreaUid(String login, Long uid) should return all UserGroupMemberships for a specific user and only UserGroups that belong to a given Area UID
Actual Behaviour
It fails to correctly identify the properties: java: Unable to implement Repository method: UserGroupMembershipRepository.findAllByUserLoginAndUserGroupAreaUid(String login,Long uid). Cannot query entity [UserGroupMembership] on non-existent property: UserGroupAreaUid
It tries to find a property named UserGroupAreaUid, which doesn't exist, instead of going through the relationships.
I tried adding a separator to the method definition to explicitly separate property names, thus declaring it as findAllByUserLoginAndUserGroup_AreaUid(String login,Long uid) , but got the same result
java: Unable to implement Repository method: UserGroupMembershipRepository.findAllByUserLoginAndUserGroup_AreaUid(String login,Long uid). Cannot query entity [UserGroupMembership] on non-existent property: UserGroup_AreaUid
What did the trick was exchanging private User user; in my UserGroupMembership entity for private User member; and then changing the findAllBy definition accordingly: findAllByMemberLoginAndUserGroupAreaUid(String login, Long uid)
I believe this is a bug caused by having fields named user and userGroup
Steps To Reproduce
No response
Environment Information
Amazon Corretto 17.0.5.8.1
Ubuntu 22.04
Example Application
No response
Version
4.0.5
The text was updated successfully, but these errors were encountered:
Expected Behavior
I'm currently porting a system that uses Spring Data JPA to Micronaut using Hibernate Reactive, and I have the following entities:
And the repository:
The method
findAllByUserLoginAndUserGroupAreaUid(String login, Long uid)
should return all UserGroupMemberships for a specific user and only UserGroups that belong to a given Area UIDActual Behaviour
It fails to correctly identify the properties:
java: Unable to implement Repository method: UserGroupMembershipRepository.findAllByUserLoginAndUserGroupAreaUid(String login,Long uid). Cannot query entity [UserGroupMembership] on non-existent property: UserGroupAreaUid
It tries to find a property named UserGroupAreaUid, which doesn't exist, instead of going through the relationships.
I tried adding a separator to the method definition to explicitly separate property names, thus declaring it as
findAllByUserLoginAndUserGroup_AreaUid(String login,Long uid)
, but got the same resultjava: Unable to implement Repository method: UserGroupMembershipRepository.findAllByUserLoginAndUserGroup_AreaUid(String login,Long uid). Cannot query entity [UserGroupMembership] on non-existent property: UserGroup_AreaUid
What did the trick was exchanging
private User user;
in myUserGroupMembership
entity forprivate User member;
and then changing the findAllBy definition accordingly:findAllByMemberLoginAndUserGroupAreaUid(String login, Long uid)
I believe this is a bug caused by having fields named
user
anduserGroup
Steps To Reproduce
No response
Environment Information
Example Application
No response
Version
4.0.5
The text was updated successfully, but these errors were encountered: