-->
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.  [ 1 post ] 
Author Message
 Post subject: Returning only specified db columns using ICriteria
PostPosted: Fri Jan 20, 2006 5:44 pm 
Newbie

Joined: Fri Jan 20, 2006 12:47 pm
Posts: 16
Location: Ottawa, On
In my app, I have a main class which is very large but links to most other data within the system. The search functionality that we are building basically allows each property and many of the relationships to other object or collections from this main object to be searched upon.

When investigating the differences between querying using the IQuery interface or ICriteria, the ICriteria interface provided a really nice, clean way of searching on all properties and collections within this object. This was great until we loaded a large amount of data into the db (900,000+ rows). Initially, I was only lazily loading collections, but not many-to-one associations and very quickly found out that the search returning a large result set was pretty much unuseable.

I then tried proxying the many-to-one associations which definitely made the generated sql query much smaller and faster, but the size of the objects reutrned was still much too large given each one contains 7 or 8 associated proxy objects.

The main problem is, when I do a search I only need 3 or 4 of the property values returned from the main object and none of the proxies. I know I can easily make this happen using an HQL query such as "select new ClassX(m.a, m.b) from Main m". The problem is that I lose all of the ICriteria funtionality which allows me to easily build a powerful search.

Is there any way that using ICriteria I can invoke functionality similar to the "select new ClassX()" style HQL and specify which specific columns I want returned? I do not want to filter using a transformer (which I think could be done) because the transformer methods are only called after the db query has been executed meaning that way more columns than I require have been returned from the db ... impacting performance.

On the other hand, is there a way that I can build my query using an ICriteria object and then extract the HQL or SQL from it without running List()? Then I could prepend this with my select new .... stuff.

If not, I will re-write using HQL, but it seems like such a waste of the ICriteria interface.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.