我开始使用QueryDsl 4
我得到了这个错误
java.lang.UnsupportedOperationException
at com.querydsl.jpa.JPASubQuery.iterate(JPASubQuery.java:72)
at com.querydsl.core.support.FetchableQueryBase.fetch(FetchableQueryBase.java:46)
at dao.SearchProjetDao.getListProjetsQueryDsl(SearchProjetDao.java:108)
at controllers.ProjetRest.getListProjetsQueryDsl(ProjetRest.java:82)
当我尝试这个子查询
QProjet prj = new QProjet("prj");
...
BooleanBuilder where_loc = new BooleanBuilder();
if( bean.commune != null ){
QLocalisation loc_2 = new QLocalisation("loc_2");
where_loc.and(prj.id.in(
JPAExpressions.select(loc_2.projet.id).from(loc_2)
.where(loc_2.commune.id.eq(bean.commune))
.fetch()
));
}
...
我以前在JPASubQuery
中使用QueryDsl 3
但它在版本4中不再存在
你把fetch放在了错误的地方。
where_loc.and(prj.id.in(
JPAExpressions.select(loc_2.projet.id).from(loc_2)
.where(loc_2.commune.id.eq(bean.commune))
// .fetch() <--- Remove
));
期望(或其他)
SubQueryExpression
- 修改后的代码选择的重载Collection
- 错误代码选择的重载。 (我认为这些应该是常量)