Hi,
I’m using Hibernate 3.x, Oracle 10g in our application. I’m using hibernate criteria with pagination option for fetching results and using projections for getting result count. The following are the queries generated by the hibernate.
Total Result Count Criteria Code criteria.setResultTransformer(Criteria.PROJECTION); totalCount=(Integer) criteria.setProjection(Projections.rowCount()).uniqueResult();
Query generated by hibernate select count(*) as y0_ from table1 this_ where this_.GroupId in (?) and this_.status in (?, ?, ?, ?) and this_.UserId=?
Pagination Results Criteria criteria.setFirstResult(startCount); criteria.setMaxResults(pageSize); result=crit.list();
Query generated by hibernate select * from ( select this_.column1 as column1_0_, this_.column2 as column2_0_, this_.column3 as column3_6_0_ from table1 this_ where this_.GroupId in (?) and this_.status in (?, ?, ?, ?) and this_.UserId=?) where rownum <= ?
I want to combine this two queries together using oracle 10g analytic function
select * from ( select this_.column1 as column1_0_, this_.column2 as column2_0_, this_.column3 as column3_6_0_, count(*) over (partition by 1) as totalcount from table1 this_ where this_.GroupId in (?) and this_.status in (?, ?, ?, ?) and this_.UserId=?) where rownum <= ?
I cannot use named query since these are all dynamically generated by criteria so Please suggest how to add this feature to hibernate criteria (suggest options like extending dialect, using formula mapping)
Thanks Jaya Murugan
|