我有以下查询,hibernate 不支持在'from' 之后嵌套的问题我试图创建一个 View ,但是没有成功,我想知道如何使用hibernate 正确运行这个查询
SELECT sum(dc.nbrDefaut) def, a.nb control,c.id_of
FROM controlequalite c ,detailscontrole dc,
(select sum(nbreControlle) nb, id_monitrice
from controlequalite group by id_monitrice) a
where c.id = dc.id_controle
and c.id_monitrice = a.id_monitrice
and c.date >= '2016-03-25 00:00:00'
group by c.id_monitrice,c.id_of;
最佳答案
对于这样的查询,最简单的方法是使用 native 查询。我假设您使用 JPA/Hibernate 作为 ORM,因此您可以简单地执行以下操作:
List<YourObject> resultList = yourEntityManager.createNativeQuery("nativeSQLhere", YourObject.class).getResultList();
关于mysql - 我如何操作嵌套查询 j2ee hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36911208/