Enhance use cases for case clause

Description

SQL supports several use cases for CASE clause, one of them:

Apparently, Criteria API doesn't handle correctly such use case. E.g. following code snippet

fails with exception:

Notable, code hibernate generates is actually correct and it could be executed to DB, but it fails with some kind of validation error.

It would be nice for Hibernate to handle such use cases of CASE clause.

Environment

Oracle JDK 1.8, Windows 10

Activity

Show:
Christian Beikov
November 17, 2020, 10:44 AM

The issue is that you can’t use predicates as expressions. Maybe Hibernate 6.0 will fix this. In the meantime, you can use the following:

Or the simpler version based on boolean logic

Christian Beikov
November 17, 2020, 10:48 AM

See

Duplicate

Assignee

Christian Beikov

Reporter

R M

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Feedback Requested

2020/11/17

Components

Affects versions

Priority

Major
Configure