-->
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.  [ 2 posts ] 
Author Message
 Post subject: Which is more performance effective ? HQL or Criteria api?
PostPosted: Thu Feb 28, 2008 5:20 am 
Newbie

Joined: Tue Dec 11, 2007 12:28 am
Posts: 5
Hi,

I have to get data from the database from different tables using multiple conditions (using joins) . so i thought of using Criteria api -- DetachedCriteria, Restrictions class etc.

But i feel the hql is simpler, also supports joins and im afraid using Criteria api may degrade the performance comparitively.

Can anyone tell me which is better to use for effective performance?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 28, 2008 11:13 am 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Both HQL and Criteria API offer the same performance as both are executed as SQL in database side. And Hibernate use the same logic for both.

What extra benefit Criteria API offers over HQL is dynamic query building. You can think about your query in terms of Objects instead of SQL.

Here is notes from hibernate docs:
Quote:
HQL is extremely powerful but some developers prefer to build queries dynamically, using an object-oriented API, rather than building query strings. Hibernate provides an intuitive Criteria query API for these cases:


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