-->
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.  [ 5 posts ] 
Author Message
 Post subject: Paging via HQL query
PostPosted: Wed Sep 07, 2005 3:51 am 
Good day!

The base concepts of a system I'm working on were designed by other people, and criteia based filtration is not suitable. So I have no other choice to write in plain HQL.

Is there any way to do paging by the means of HQL (something like 'rownum' etc.)? I heard there was a contribution where such problem was solved.

Any help will be surely appreciated.

Best regards,
Dio.


Top
  
 
 Post subject: Manralf
PostPosted: Wed Sep 07, 2005 5:43 am 
Look at this : http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html#queryhql-tipstricks


Top
  
 
 Post subject: Re: Manralf
PostPosted: Wed Sep 07, 2005 6:25 am 
Anonymous wrote:


Thanks alot, but I've already seen that. And as I told there is no way I could use such technique. I need to perform paging with HQL only. Is it possible?


Top
  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 11:50 am 
Regular
Regular

Joined: Tue May 24, 2005 12:55 pm
Posts: 56
Hibernate is documented very well, if you can't find a way on the Hibernate site then it likely can't be done.


Top
 Profile  
 
 Post subject: Re: Paging via HQL query
PostPosted: Fri Feb 18, 2011 12:41 pm 
Newbie

Joined: Mon Feb 14, 2011 6:17 pm
Posts: 5
You might be able to do it by assigning your HQL to IQUery using "CreateQuery" method of nhibernate current session object
and then can use as same way as we can do with creteria something like this:

Session session = HibernateTemplet.currentSession();
Query query = session.createQuery("your HQL");
query.setFirstResult(1);
query.setMaxResults(2);
List results = query.list();

I am not sure but you should be able to achieve it by this.
Let me know if you find a better way.


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.