simple case statement failing with enum due to missing expected type

Description

The type information from context is missing when using the CriteriaBuilder.selectCase(Expression<? extends C> expression).when(C condition, Expression<? extends R> result).
It's working however perfectly when using CriteriaBuilder.selectCase().when(Expression<Boolean> condition, Expression<? extends R> result).

By debugging the code, it appears that the type information from expression is not reused in condition, which leads to type conversion errors.

Attachments

2

Activity

Show:

Maillefer Jean-David May 2, 2017 at 9:15 PM

When using postgresql, the error is very similar to the one described in

Maillefer Jean-David May 2, 2017 at 9:00 PM
Edited

Added test case JPAUnitTestCase.

When using the searched selectCase (without argument), then everything is fine.
When using the simple _valued _selectCase (with one argument), then the custom type (in this case for enum) is not found.

I would expect that the expected type from the argument to selectCase (here: contactRoot.get("type")) should be re-used for the condition (ContactTypeEnum.INDIVIDU).

Note: the test case contains the workaround.
Which is to use the searched selectCase instead of the simple one.

Maillefer Jean-David May 2, 2017 at 5:44 PM
Edited

Similar to (but not fixed for this use case)

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created May 2, 2017 at 5:43 PM
Updated May 2, 2017 at 11:06 PM