Can't compare test expression of type [BasicSqmPathSource(type : Enum)] with element of type [basicType@5(java.lang.Integer,4)]
Activity

Gavin King August 14, 2023 at 4:52 PM
As I posted below:
if it isn’t fixed as a side-effect of those changes, you might be out of luck.
So, sorry, you’re out of luck.
Jonas Gernot Steinke August 14, 2023 at 6:25 AM
I can not understand why this issue was closed.
The last commit is from June 28 and I have replied on June 30 that only the error message has changed. With the specified version (6.3.0.CR1) is still the same error message: Cannot compare left expression of type 'java.lang.Enum' with right expression of type 'java.lang.Integer'

Gavin King June 30, 2023 at 11:17 AM
Well, I have another big raft of changes coming in , but if it isn’t fixed as a side-effect of those changes, you might be out of luck.
Jonas Gernot Steinke June 30, 2023 at 10:59 AM
I tested the changes by building hibernate from source (33a3ff2994d8412ef3c3d68ebe8af5574d05d597) and it still does not work. The error message has changed a little (which seems unrelated to the changes from ) to: Cannot compare left expression of type 'java.lang.Enum' with right expression of type 'java.lang.Integer'
Here the full stack trace:
Jonas Gernot Steinke June 29, 2023 at 9:02 AM
Thank you for taking care of the problem so quickly. I will check in a timely manner if their fix helps.
You are right, the comparison with integer literal or string literal is not good. In the case of integer literals, a high source of error, but also useful in some cases. I look forward to upcoming changes like the ones you mentioned in your comment, if they are coming.
In this case, it was the different behavior of Hibernate related to enum and enum as generic types that confused me.
With the update of Vaadin from version 14 to 24, Hibernate was also updated. In the process, I noticed a problem in the current Hibernate versions.
Normally Vaadin 24 uses Hibernate 6.2.2.Final, but this version also has problems with generic types and I'm switching to 6.2.4.Final, that fixes it for another project.
Now I found another issue in Hibernate also related to generic types.
I have created a small Vaadin 24 project to illustrate the issue. This example can be found on GitHub:
I have created two classes ItemA and ItemB. ItemA uses an enum and ItemB extends AbstractItem. This uses a generic type which must be an enum.
Now I want to use < with the enum field and a constant within an query.
In the case of ItemA this is not a problem at all, but for ItemB I get the following exception:
Can't compare test expression of type [BasicSqmPathSource(type : Enum)] with element of type [basicType@5(java.lang.Integer,4)]
See following code snippets fore context. Actual sources are linked below.
I use types like ItemB in many cases on Hibernate 5.1.0 without problems.