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: is it possible to get SQL from Criteria?
PostPosted: Fri Dec 10, 2004 10:26 pm 
Newbie

Joined: Tue Jul 06, 2004 4:40 am
Posts: 9
Location: Slovakia
Hibernate version:2

I have a Criteria generated by user actions (user can define some filters and so...).
But now, there are too many records, so criteria.list() takes a very long time and becose I just need primary keys of this records,
I wish to use somethilng like this...

( method getCriteria() generates Criteria by user actions and so..)

Code:
ArrayList idList = new ArrayList();
Criteria crit = getCriteria();
Object obj = crit.uniqueResult();
if ( obj == null) {
   log.error( "nothing found...");
   return idList;
} else{
   String primaryKeyPropertyName = HibernateProvider.primaryKeyPropertyName( obj);
   log.debug( "primary key: " + primaryKeyPropertyName);
}


and then I wish to select primary keys from database by Criteria
(not whole objects, but only primary keys... )
and put them into idList

is it possible?
thanx...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 11, 2004 9:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 11, 2004 8:24 pm 
Newbie

Joined: Tue Jul 06, 2004 4:40 am
Posts: 9
Location: Slovakia
so I resolved it :)...

the idea is the same as count(*) hack :)))


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.