Hibernate JPA子查询的问题
我开始使用Hibernate JPA子查询的问题,hibernate,jpa,querydsl,Hibernate,Jpa,Querydsl,我开始使用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.getList
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()
));
}
...
我曾经在
QueryDsl 3
中使用JPASubQuery
,但在版本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
));
其中位置和(prj.id.in(
JPAExpressions.select(loc_2.projet.id).from(loc_2)
.where(loc_2.commune.id.eq(bean.commune))
//.fetch()更新了答案,如果正确的jar.Fully限定路径是com.querydsl.jpa.JPASubQuery
更新了答案。谢谢@Lesiak it work now…只需删除错误的答案,以免混淆