Hi,
We are migrating our code base from Hibernate 5 to 6.
Some of our entities have different types of columns that are treated as strings, for instance:
Enum annotated with @Enumerated(EnumType.STRING)
UserType (de)serializing to/from a string(VARCHAR) DB column (we plan to move these to use an AttributeConverter)
Then we have queries where we apply the “like” predicate on such a string-like field. While it used to work on Hibernate 5, as effectively the columns were saved/retrieved as strings, now it throws a ```
SemanticException saying that the operand is not a String.
How can we achieve a similar behavior on Hibernate 6?
Hi @pela, this sounds very similar to [HHH-17693] - Hibernate JIRA, though that issue was only about AttributeConverters it might have solved your problem too. The fix for is included in Hibernate version 6.4.4.Final, which is the latest release at time of writing. Could you please test with that and let us know if the issue persists?
Hi,
I’ve got some contrasting results on 6.4.4.Final
It works for both @Enumerated(EnumType.STRING) and custom type with AttributeConverter.
For example, if I use a CriteriaQuery with predicates like cb.like(root.get("myEnum"), "%_A") or cb.like(root.get("customString"), "MY%")
It does not work if I use a ParameterExpression as a parameter, throwing QueryArgumentException
Similarly with HQL query, it works unless I use binding parameters.
I’m also seeing that the reproducer project attached to HHH-17693 still fails after updating to 6.4.4.Final, throwing QueryArgumentException.
You’re right @pela, there seems to still be an issue with type validation when using a parameter expression in a like predicate involving a converted path. Could you please be so kind as to open a new followup Jira issue for that? We will look into it as soon as possible, thanks.