Where语句中的Hibernate案例

时间:2012-03-22 13:07:43

标签: hibernate case member

您好我尝试以下选择:当设置了group属性时,用户必须是成员:

FROM Appointment a WHERE (CASE WHEN a.group!=null THEN :user MEMBER OF a.group.groupMembers ELSE true END)

但我明白了:

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: MEMBER near line 1, column 88 [FROM de.lyth.appointment.model.Appointment a WHERE (CASE when a.group!=null THEN :user MEMBER OF a.group.groupMembers ELSE true END) ]

我怎么能达到这个目的?

感谢

编辑: 我改为:

解决了这个问题
(a.group==null OR :user MEMBER OF a.group.groupMembers) 

1 个答案:

答案 0 :(得分:-1)

我通过更改为: (a.group == null OR:用户成员a.group.groupMembers)