-->
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.  [ 2 posts ] 
Author Message
 Post subject: Map Query to dto
PostPosted: Mon Mar 16, 2009 8:47 pm 
Newbie

Joined: Mon Mar 16, 2009 8:44 pm
Posts: 1
Hello,
I have query which is returning different objects back.

Is there any way that I can map the return result automatically to my dto class?

Thanks,
Niko


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 2:20 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Can you make your ques a bit clearer. May be with an eg.

Do you mean that:
"select prop1, prop2 from ClassA where prop3=:someValue" is your query
and you want this HQL to return an object contatining prop1 and prop2 instead.

In that case you can write the HQL as:

select new TempObject(prop1, prop2) from ClassA where prop3=:someValue

Make sure TempObject class has a matching a constructor. There is no need for mapping the TempObject class.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.