I am fetching some records in following manner :
Code:
DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class);
subCriteria.add(Restrictions.eq("employeeType.id", "EX"));
subCriteria.setProjection(Projections.property("departmentId"));
DetachedCriteria criteria = DetachedCriteria.forClass(Employee.class);
criteria.add(Property.forName("departmentId").in(subCriteria));
List<Employee> employees = baseDao.getEntities(Employee.class, criteria);
Basically following is my sql query for above Criteria :
Code:
SELECT * FROM EMPLOYEE WHERE DEPARTMENT_ID IN
(SELECT DEPARTMENT_ID FROM EMPLOYEE WHERE EMPLOYEE_TYPE_ID = 'EX')
But my requirement is to do some thing like :
Code:
SELECT * FROM EMPLOYEE WHERE DEPARTMENT_ID IN
(SELECT DEPARTMENT_ID FROM EMPLOYEE WHERE EMPLOYEE_TYPE_ID = 'EX' AND ROWNUM <= 20)
Can some one guide me for the same? It would be great help. Thanks in advance,
- Chirag