Case/when in criteria with string literal result fails type checking

Description

The strings in the criteria query are always transformed into parameters, even if you use CriteriaBuiler#literal(). This implicit parameter binding mechanism of all literals in criteria queries conflicts with the type checking in the SearchedCaseNode. The ParameterNode doesn't carry any data type information.

Ugly workaround, forcing creation of LiteralNode:

Environment

None

Activity

Show:
Cody Lerum
November 16, 2015, 9:07 PM

There is already a PR open with a test case, but it probably needs to be rebased to 5.0 https://github.com/hibernate/hibernate-orm/pull/801

Cody Lerum
November 17, 2015, 12:18 AM
Steve Ebersole
November 18, 2015, 4:15 AM

Trying to understand. So does this fail on 5.0? your comment makes me think it works.

Rafael Chaves
November 18, 2015, 10:36 AM

Steve, this causes the exception in either version:

This is a workaround for both versions (using a number as literal):

This is a workaround only for 5.0.2 (using a Java boolean literal directly instead of wrapped by cb.literal()):

Marvin Froeder
May 17, 2016, 6:21 AM

Any chance of having this fixed on 4.3 series?

Assignee

Andrea Boriero

Reporter

Christian Bauer

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure