-->
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: selecting certain fields of a table into an object
PostPosted: Tue Jul 25, 2006 9:14 am 
Newbie

Joined: Tue Jul 25, 2006 8:50 am
Posts: 8
I want to select only some fields of a table into an object setting other fields of the table to nulls.i want to get it done by the hibernate itself.
e.g.
select fullName,designation,termAcceptance from UserProfileVO where userId=15

i want to get only fullName,designation & termAcceptance of UserProfileVO and all other fields should be null.

how can i do that???

_________________
mks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 9:44 am 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Create a constructor taking required fields.

Code:
public UserProfileVO( String fullName, String designation, boolean termAcceptance ){
   this.fullName = fullName;
   this.designation = designation;
   this.termAcceptance = termAcceptance;
}


then execute following query

Code:
select new UserProfileVO( fullName, designation, termAcceptance ) from UserProfileVO where userId='15'


it should give you object with only the required fields populated. If i am correct, thi should be available from hibernate version 3.1


Top
 Profile  
 
 Post subject: Thanx a lot
PostPosted: Wed Jul 26, 2006 1:44 am 
Newbie

Joined: Tue Jul 25, 2006 8:50 am
Posts: 8
Hi

Thanx a lot. This is working fine...

_________________
mks


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.