-->
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: Restrict Resultset
PostPosted: Wed Apr 15, 2009 1:22 am 
Newbie

Joined: Mon Feb 23, 2009 9:08 am
Posts: 9
Hi newbie to hibernate and just wanted to get your thoughts on the following:

I have a POJO called Client that contains all information about a client ie.: firstname, surname, dob... etc.

I implement a search functionality that search for clients by Surname but when I view the sql generated by hibernate i noticed that hibernate fetches all fields defined in the Client POJO. ie.: SELECT FirstName, Surname, DOB, Occupation, Income FROM Client

However for performance i would prefer to restrict the output to SELECT FirstName, Surname FROM Client.

What would be the best way to achieve this in hibernate, i mean theres no point returning/fetching all attributes from the Client table when im only using the firstname and surname to display the found clients.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 1:54 am 
Newbie

Joined: Sat Mar 28, 2009 5:47 pm
Posts: 14
Just guessing here, but doesn't:

Code:
"select firstname, surname from Client where surname=:name"


do the right thing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 5:38 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Another way could be to use lazy property fetching.

But I don't think it's necessary to exclude some columns for performance reasons.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.