-->
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: HQL join query set.
PostPosted: Wed Mar 19, 2008 6:36 am 
Newbie

Joined: Wed Mar 19, 2008 3:38 am
Posts: 8
Location: Chennai, India
Hi,

I am new to hibernate and have a question. Its a simple one but dint find answers anywhere. I do a join and select 6 fields. The thing is that it goes on to the inner level.

"select distinct " +
"sc.componentVersion.component.name as cname, sc.componentVersion.component.description " +
",sc.componentVersion.version, sc.componentVersion.description " +
",sc.componentVersion.component.group.name, sc.componentVersion.component.group.description " +
"from Stack as s join s.stackComponents as sc " +
"where s.name = :stackNameQuery"



StackComponent has a foreign key reference to Stack Table.
StackComponent has a foreign key reference to ComponentVersion
ComponentVersion has a foriegn key reference to Components.
Components has a foriegn key reference to Group.


Now my question is when i execute the above query i get a List of Object objects. How do i get the actual values of sc.componentVersion.componentName and other fields?

Its really very urgent. I would be really grateful if somebody help me out.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 9:08 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I think it's an object array. Each list entry is one row of results, and the object arrays contain the data which you can cast to String or Byte or whatever.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 9:12 am 
Newbie

Joined: Wed Mar 19, 2008 3:38 am
Posts: 8
Location: Chennai, India
Hi,

Yeah your right. I get an Object array. But i am not able to cast the Object object into any other type. I tried casting it to string since name is stored as string in database.

I found a solution for this. Its to create a new DAO class for that query and make the query return array of objects of that type. But can somebody help me in using the Object type returned.


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.