我需要使用HQL对象构造器功能,我还需要对特定的列使用distinct关键字,最后我要按如下方式使用order:
@Query("select distinct (a.id) new com.ResultBean " +
"(a.id, a.title, a.price, b.status) from EntityA a " +
"LEFT JOIN EntityB b with (a.id=b.a.id ) order by a.id,b.id")
这可能吗?
您可以简单地使用group by
,以便元素是不同的:
@Query("select new com.ResultBean" +
"(a.id, a.title, a.price, b.status) from EntityA a " +
"LEFT JOIN EntityB b with (a.id=b.a.id ) group by a.id, a.title, a.price, b.status order by a.id,b.id")
List<ResultBean> getResultBean();