This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes fetching records by using hql and criteria is taking more time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "fetching records by using hql and criteria is taking more time" Watch "fetching records by using hql and criteria is taking more time" New topic
Author

fetching records by using hql and criteria is taking more time

vijay akni kumar
Greenhorn

Joined: Aug 11, 2008
Posts: 12
Hi All
I have a hql query , when ever i iam getting 400 -500 records it is taking 3-4 sec. but when iam getting around 5000 record it is taking more time around 3 min in local system.

the method is
public List getAllSourcedCandiadtes(String startingDate, String endingDate) {

return (List) getHibernateTemplate().find(

"select distinct prospectiveCandidates from ProspectiveCandidates prospectiveCandidates where prospectiveCandidates.appliedDate between '" + startingDate + "' and '" + endingDate + "' and (prospectiveCandidates.sourceName != 'candidate' ) and (prospectiveCandidates.sourceResume !=null )");
}

the query is working fine but I want to improve the performance, even i tried using criteria API
Criteria crit = session.createCriteria(ProspectiveCandidates.class)
.add(Expression.between("appliedDate", new Date(startDate.getTime()),new Date(endDate.getTime())));

crit.add(Restrictions.and(Restrictions.ne("sourceName","candidate"), Restrictions.isNotNull("sourceResume")));

List abcd= crit.list();

return abcd;

I am able to get records with criteria API but iam not able to improve the performance.
please suggest me ................
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fetching records by using hql and criteria is taking more time