• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hql top

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Is it possible to get "top 2" in Hql?

I have this Audit Hibernaet donain object that contains
date,id,description



Thank you!
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a query as in create query from HQL. Then read into setFetchSize or setFirstResult.
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am using HibernateTemplate of Spring I saw the API containing setFetchSize,
Thank you
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've become accustomed to using criteria searches. It is easy to limit result size then:

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you run DetachedCriteria with inner query?
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you can perform joins with detatched criteria, but I'm not too acquainted with it. I've mostly used it to dynamically build where clauses. The bit of joining I did I found more complicated than writing the whole HQL so I haven't gone in dept. Maybe someone else can provide more info on this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic