hibernate - Hibenate criteria API with "in clause" -
i have native sql, want move hibenate's criteria api,
here is:
select * hv_lma_vi t0 t0.hv_id in (select t2.hv_id z_lszerg_hv t4, z_lsz_erg t3, herstellungsvariante t2 ((t3.lsz_id = 204) , ((t4.hv_id = t2.hv_id) , ((t3.erg_id = t4.erg_id) , (t3.lsz_id = t4.lsz_id)))));
all needed entites (hv_lma_vi, z_lszerg_hv, z_lsz_erg,)
exist.
from can understand of query, close to:
detachedcriteria detachedcriteria = detachedcriteria.forclass(herstellungsvariante.class) .createalias("propertytot3", "t3") .createalias("t3.propertytot4", "t4") .add(restrictions.eq("t3.lsz_id", 204)) .setprojection(projections.property("hv_id")); session.createcriteria(hv_lma_vi.class) .add(property.forname("hv_id").in(detachedcriteria)) .list();
Comments
Post a Comment