Java 在HQL中如何使用case when和between

Java 在HQL中如何使用case when和between,java,hql,Java,Hql,我想获取startDate和endDate之间的ProjectTemplate。在某些情况下,endDate可能为空。在这种情况下,我想将currentDate设置为endDate。这是我的问题 session.createQuery("from ProjectTemplate where :currentDate between startDate AND case when endDate is null then :currentDate else endDate ")

我想获取startDate和endDate之间的
ProjectTemplate
。在某些情况下,endDate可能为空。在这种情况下,我想将currentDate设置为endDate。这是我的问题

 session.createQuery("from ProjectTemplate where :currentDate between startDate AND case when endDate is null then :currentDate else endDate ")
                        .setDate("currentDate", new Date())
                        .list();
它会产生一个错误

antlr.MismatchedTokenException: expecting "end", found 'null'

它说你必须.close.your case语句和'end'关键字它说你必须.close.your case语句和'end'关键字