simple case statement failing with enum due to missing expected type
Description
Attachments
2
relates to
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 PMEdited
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 PMEdited
Similar to (but not fixed for this use case)
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 incondition
, which leads to type conversion errors.