[hibernate-dev] Should LiteralExpression support Enum?

Guillaume Smet guillaume.smet at gmail.com
Fri Nov 2 11:18:31 EDT 2018


Hi,

Getting back to this issue.

If it were only for the render() case, I would have registered the enums as
parameters as done before, in all cases.

But considering the renderProjection() case where we should avoid
parameters, I wonder if we should register a ValueHandler for enums.

Obviously, literal expressions should not be used to build predicates on
enum columns as they could be stored as ordinals but it would be good
enough to bring back 5.1 compatibility.

WDYT?

-- 
Guillaume

On Mon, Oct 8, 2018 at 8:57 PM Gail Badner <gbadner at redhat.com> wrote:

> HHH-13016 looks like a duplicate of HHH-12184. Both mention that this
> worked in 5.1.10.
>
> The spec is clear that, for queries, this is supported. The overview for
> Criteria API states, "The semantics of criteria queries are designed to
> reflect those of Java Persistence query language queries."
>
>  IMO, this should be supported for Critera queries as well.
>
>
>
> On Mon, Oct 8, 2018 at 5:30 AM Guillaume Smet <guillaume.smet at gmail.com>
> wrote:
>
>> Hi,
>>
>> We had an interesting test case posted this week-end, namely
>> https://github.com/hibernate/hibernate-orm/pull/2562/files .
>>
>> Apparently, enums as result of case expressions were (sort of) supported
>> in
>> 5.1, whereas they are not anymore in 5.3: you end up with a NPE.
>>
>> The issue is that we don't have a ValueHandler for enums and thus the
>> handler in
>>
>> https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/LiteralExpression.java#L88
>> is null.
>>
>> Not sure if it's something we should support tbh. I mean you can use the
>> name of the enum instead and I think it would be good enough.
>>
>> But even if we decide to not support it, I think we should probably
>> provide
>> a better error than a NPE.
>>
>> Thoughts?
>>
>> --
>> Guillaume
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>


More information about the hibernate-dev mailing list