I'm developing a project in Spring boot 3 and i have an issue with Hibernete "criteriaBuilder" to querying a "@ElementCollection" with an enum Authority.
// UserEntity.class
@ElementCollection(targetClass = Authority.class, fetch = FetchType.EAGER)
@CollectionTable(name = "t_user_authorities")
@Enumerated(EnumType.STRING)
@ToString.Exclude
private Set<Authority> authorities;
In my Enum
public enum Authority{
CAN_POST
}
In the JpaSpecification
...
Join<Authority, User> authorityUserJoin = root.join("authorities"); // Wanna join the Authority here
return criteriaBuilder.like(
criteriaBuilder.lower(authorityUserJoin.get("authorities")), // If it was Entity, 'd be "authority" as property here
'%'+value.toLowerCase()+'%'
);
Helps