Hello, i have spent most of the day trying to figure out what is wrong here, maybe i am missing some key point or there is a known bug (could not find in jira).
For some reason whatever is entered inside .in() does not get validated correctly. (I tried to convert the ‘reason’ variable into Set with 1 item too - same result (as well as .in() according to javadocs is taking in objects without collection so not expecting difference here)
Expression forbiddenByReason = root.get(Description_.reasons).in(reason), builder.literal(1L)).otherwise(builder.literal(0L));
Then after calling createQuery the error (pasted at the bottom) comes up.
For clarity i am attaching relevant code:
public enum Reason {
ALLOW_AS_PARENT,
ALLOW_LEGAL_ENTITY;
}
@Generated(value = “org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor”)
@StaticMetamodel(Description.class)
public abstract class Description_ {
public static volatile SetAttribute<Description, Reason> forbiddenReasons;
}
Error:
java.lang.IllegalArgumentException: Parameter value [ALLOW_AS_PARENT] did not match expected type [java.util.Set (n/a)] at org.hibernate.jpa.spi.BaseQueryImpl.validateBinding(BaseQueryImpl.java:874) at org.hibernate.jpa.internal.QueryImpl.access$000(QueryImpl.java:80) at org.hibernate.jpa.internal.QueryImpl$ParameterRegistrationImpl.bindValue(QueryImpl.java:248) at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:620) at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:180) at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:49) at org.hibernate.jpa.criteria.compile.CriteriaCompiler$1$1.bind(CriteriaCompiler.java:126) at org.hibernate.jpa.criteria.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:386) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:147) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:736)