This code:
Code:
Criteria criteria = getSession().createCriteria(Solicita.class, "solicita");
criteria.setProjection(Projections.property("solicita.numero"));
criteria.add(Restrictions.eq("solicita.flgAprov", (byte)1));
Criteria subCriteria = getSession().createCriteria(InicCart.class, "iniccart");
subCriteria.createAlias("iniccart.solicita", "solicita");
subCriteria.setProjection(Projections.property("solicita.pkSolicita"));
criteria.add(Restrictions.not(Restrictions.in("solicita.pkSolicita", subCriteria.list().toArray())));
criteria.setMaxResults(1);
return (Integer)criteria.uniqueResult();
Results in:
Code:
Hibernate:
select
solicita1_.PkSolicita as y0_
from
iniccart this_
inner join
solicita solicita1_
on this_.FkSolicita=solicita1_.PkSolicita
Hibernate:
select
this_.Numero as y0_
from
solicita this_
where
this_.FlgAprov=?
and not (this_.PkSolicita in (?, ?, ?, ?)) limit ?
Nice, but, something like this is already very enough:
Quote:
select
this_.Numero as y0_
from
solicita this_
where
this_.FlgAprov=?
and not (this_.PkSolicita in (select FkSolicita from iniccart)) limit ?
Is there any how?
Thanks!