-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL and Criteria Queries
PostPosted: Thu Aug 24, 2006 4:32 am 
Newbie

Joined: Mon May 29, 2006 6:14 am
Posts: 17
What is different between HQL and Criteria Queries. Where could be used HQL and Where could be used Criteria Queries.

(I think Criteria Queries is very easy for complex query?)

Thank you!


Top
 Profile  
 
 Post subject: Criteria use
PostPosted: Thu Aug 24, 2006 12:24 pm 
Newbie

Joined: Thu Aug 24, 2006 11:58 am
Posts: 5
Criteria queries are best used where you do not know which query parameters will be selected. For example: if you had a list of books, you could provide a screen which allowed the user to search for a book by the author, ISBN, title, date published, publisher, etc. In HQL you would have to build a string containing the query. That is doable, but a also a pain. With the criteria, you just add restrictions to the query criteria which correspond to the parameters actually filled in by the user.


Top
 Profile  
 
 Post subject: Re: Criteria use
PostPosted: Thu Aug 24, 2006 5:05 pm 
Newbie

Joined: Thu Jul 06, 2006 12:59 pm
Posts: 6
Location: San Francisco
I would also add that Criteria queries can be less flexible than HQL. I greatly prefer them over HQL, but I have run in to several places where bugs or simple lack of functionality preclude using the Criteria API. Try it, but know that you may not be able to make it do what you need.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.