是否可以像以下示例一样使用CaseBuilder
?我们正在使用Querydsl和JPA / Hibernate设置。
public class Foo {
Bar bar
}
public class Bar {}
// query:
Expression<Boolean> isNull = new CaseBuilder()
.when(foo.bar.isNull()).then(false)
.otherwise(true)
new JPAQuery(em)
.from(foo)
.leftJoin(foo.bar)
.list(foo.name, isNull);
尝试类似的查询时,我收到以下错误:
java.lang.ClassCastException: org.hibernate.hql.internal.ast.tree.ParameterNode cannot be cast to org.hibernate.hql.internal.ast.tree.SelectExpression
at org.hibernate.hql.internal.ast.tree.CaseNode.getFirstThenNode(CaseNode.java:43)
at org.hibernate.hql.internal.ast.tree.CaseNode.getDataType(CaseNode.java:39)
at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:152)
...