Following a hibernate upgrade to 6 - I have tried 6.1.x, 6.2.x, 6.3.x I cannot fix the following relationship and associated queries that previously worked in 5.x
@CollectionTable(name = "user_role", joinColumns = {@JoinColumn(name="user_id")})
@ElementCollection(targetClass = Role.class)
@Enumerated
@Column(name = "role_id", nullable = false)
private Set<Role> roles = new HashSet<>();
Role is an enum and user_role is a two column join table [user_id, role_id]
In the query there where clause cannot be provided whereas is worked in hibernate 5.x
WHERE roles = org.package.Role.ROLE_ENUM
throws this
class org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl cannot be cast to class org.hibernate.metamodel.mapping.BasicValuedMapping (org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl and org.hibernate.metamodel.mapping.BasicValuedMapping are in unnamed module of loader ‘app’)
–
It is a collection so fair enough but any attempts to refine… for example
WHERE roles.name = org.package.Role.ROLE_ENUM
cause the following…
Caused by: java.lang.IllegalStateException: Basic paths cannot be dereferenced