同一属性的 Hibernate hql 多个 case 语句

Hibernate hql multiple case statement for same attribute

我正在将我的 sql 更改为 hql,并且在 sql 我有这个

CASE `Leave_Type`
    WHEN 1 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Annual Leave', concat('Annual Leave: ', `Leave_Comments`))
    WHEN 2 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Sick Leave', concat('Sick Leave: ', `Leave_Comments`))
    WHEN 3 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Maternity/Paternity Leave', concat('Maternity/Paternity Leave: ', `Leave_Comments`))
    WHEN 4 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Family Leave', concat('Family Leave: ', `Leave_Comments`))
    WHEN 5 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Study Leave', concat('Study Leave: ', `Leave_Comments`))
    WHEN 6 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Unpaid Leave', concat('Unpaid Leave: ', `Leave_Comments`))
    WHEN 7 THEN IF(STRCMP(`Leave_Comments`,'') = 0, 'Other Leave', concat('Other Leave: ', `Leave_Comments`))
END As 'text',

我尝试通过以下尝试将其移植到 hql,但出现错误

org.hibernate.hql.internal.ast.QuerySyntaxException: expecting \"end\", found 'else' near line 1, column 594 

像这样的 sql 的正确 hql 等价物是什么?

HQL 尝试:

(case when l.leave_Type = 1 then (case when strcmp(l.leave_Comments,'') = 0 then 'Annual Leave' else concat('Annual Leave: ', l.leave_Comments) else 
(case when l.leave_Type = 2 then (case when strcmp(l.leave_Comments,'') = 0 then 'Sick Leave' else concat('Annual Leave: ', l.leave_Comments) end) else 
(case when l.leave_Type = 3 then (case when strcmp(l.leave_Comments,'') = 0 then 'Maternity/Paternity Leave' else concat('Maternity/Paternity Leave: ', l.leave_Comments) end) else 
(case when l.leave_Type = 4 then (case when strcmp(l.leave_Comments,'') = 0 then 'Family Leave' else concat('Family Leave: ', l.leave_Comments) end) else 
(case when l.leave_Type = 5 then (case when strcmp(l.leave_Comments,'') = 0 then 'Study Leave' else concat('Study Leave: ', l.leave_Comments) end) else 
(case when l.leave_Type = 6 then (case when strcmp(l.leave_Comments,'') = 0 then 'Unpaid Leave' else concat('UnpaidLeave: ', l.leave_Comments) end) else 
(case when l.leave_Type = 7 then (case when strcmp(l.leave_Comments,'') = 0 then 'Other Leave' else concat('Other Leave: ', l.leave_Comments) end) else null end) end) end) end) end)) end) end)
case when l.leave_Type = 1 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Annual Leave' else concat('Annual Leave: ', l.leave_Comments)  end)
when l.leave_Type = 2 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Sick Leave' else concat('Annual Leave: ', l.leave_Comments) end) 
when l.leave_Type = 3 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Maternity/Paternity Leave' else concat('Maternity/Paternity Leave: ', l.leave_Comments) end) 
when l.leave_Type = 4 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Family Leave' else concat('Family Leave: ', l.leave_Comments) end) 
when l.leave_Type = 5 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Study Leave' else concat('Study Leave: ', l.leave_Comments) end) 
when l.leave_Type = 6 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Unpaid Leave' else concat('UnpaidLeave: ', l.leave_Comments) end) 
when l.leave_Type = 7 then 
    (case when strcmp(l.leave_Comments,'') = 0 then 'Other Leave' else concat('Other Leave: ', l.leave_Comments) end) 
else NULL end