DetachedCriteria subQuery = DetachedCriteria.forClass(Moeda.class, "subMoeda");
subQuery.add(Expression.eq("subMoeda.nome", "Real"));
subQuery.setProjection(Projections.rowCount());
Criteria criteria = getSession().createCriteria(Moeda.class, "moeda");
criteria.add(Property.forName("moeda.id").eq(subQuery));
List lista = criteria.list();
CONSOLE:
select
this_.id as id5_0_,
this_.nome as nome5_0_,
this_.observacao as observacao5_0_,
this_.cifra as cifra5_0_,
this_.divisor as divisor5_0_,
this_.dataIni as dataIni5_0_,
this_.dataFim as dataFim5_0_
from
Moeda this_
where
this_.id = (
select
count(*) as y0_
from
Moeda this0__
where
this0__.nome=?
)
Nenhum comentário:
Postar um comentário