SELECT *
FROM service_type
WHERE EXISTS (SELECT 1
FROM service
WHERE service.active = 1
AND service.is_57 = service_type.id)
Criteria criteria = session.createCriteria(ServiceType.class, "servicetype");
DetachedCriteria serviceCriteria = DetachedCriteria.forClass(Services.class, "service");
serviceCriteria.add(Restrictions.eq("ACTIVE", new Integer(1)));
serviceCriteria.add(Property.forName("servicetype.ID").eqProperty("service.IS_57"));
criteria.add(Subqueries.exists(serviceCriteria.setProjection(Projections.property("service.ID"))));
return criteria.list();
Subscribe to:
Post Comments (Atom)
Please give me HQl for below Query.
ReplyDeleteselect * from tariff a where exists (
select 1 from (select max(VERSION) VERSION , UTILITYID from TARIFF group by UTILITYID ) b
where a.VERSION = b.VERSION and a.UTILITYID = b.UTILITYID )