-->
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: Join and DTO
PostPosted: Wed Nov 04, 2009 6:16 pm 
Newbie

Joined: Sun Oct 11, 2009 7:17 pm
Posts: 8
Hi

I have a HSQL query that uses many tables and I'm not sure how to access the results.

To simply things

I have the following code

Code:
Session s = HibernateUtil.getCurrentSession();
SQLQuery query = s.createSQLQuery("select customer.name, business.location from customer, business");
      
query.list();



What are the objects returned in the list?

Can I make a class just for those results?

Code:
class Results {
     String name;
     String location;
}


Cheers

_________________
Kremsoft
Software Development Outsourcing http://www.kremsoft.com


Top
 Profile  
 
 Post subject: Re: Join and DTO
PostPosted: Wed Nov 04, 2009 7:02 pm 
Newbie

Joined: Sun Oct 11, 2009 7:17 pm
Posts: 8
A legendary friend has already pointed me to the answer

Query query = s.createSQLQuery(SQL_QUERY).setResultTransformer(Transformers.aliasToBean(TestDTO.class));

TestDTO is a DTO that for this example has two Strings with getters and setters. Hibernate will populate it for you and job done!

_________________
Kremsoft
Software Development Outsourcing http://www.kremsoft.com


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.