-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to apply page size Detached Criteria used as sub select
PostPosted: Mon Jul 02, 2012 2:03 pm 
Newbie

Joined: Mon Jul 02, 2012 1:41 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.