-->
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: Help casting query object HQL
PostPosted: Wed Sep 06, 2006 4:47 pm 
Newbie

Joined: Thu Jun 15, 2006 5:58 pm
Posts: 18
I have a HQL query where i select the column from different tables. I have a problem casting the query object. Can some one tell
how to iterate over this query object and get the individual columns.


sql.append(" select contract.organization.name, contract.organization.orgLevel, contractseason.season.name,")
.append(" contractseason.contractStatus, contractproduct.products.name ")
.append(" from ContractSeason contractseason join contractseason.organizationContracts contract " )
.append(" join contractseason.contractprod contractproduct ");
Query q = sess.createQuery(sql.toString());

Can somebody help me on this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:30 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
As you have the query, you will get an Object[] for each row returned.

If you want to be more specific in accessing the returned data, take a look at dynamic instanciation -- i.e.
Code:
SELECT new CustomBean(obj1.prop1, obj2.prop1, ...) FROM Object1 obj1 JOIN obj1.object2 obj2


Curtis

_________________
---- Don't forget to rate! ----


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.