如何在休眠条件中表达此查询?
select SUM (tabla2.valor1)
from tabla1 INNER JOIN
tabla2 ON tabla1.ID = tabla2.ID
where tabla1.ID = 1
谢谢!
最佳答案
您可以使用Projections
,例如
getSessionFactory() //this is the session factory, initialized with-> new Configuration().configure().buildSessionFactory()
.openSession()
.createCriteria(tabla1.class)
.createAlias("tabla2.id", "tab2", JoinType.INNER_JOIN)
.setProjection(Projections.sum("tab2.valor1"));