-->
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: Objects being return as.....objects
PostPosted: Tue Nov 04, 2003 12:50 pm 
Newbie

Joined: Wed Oct 29, 2003 10:47 am
Posts: 7
Location: Waukesha, WI
I'm using HQL as opposed to the Criteria API (which I usually use), and i'm running into a problem where the Objects I get back come back as type Object. When I try to cast them, I get ClassCastExecptions (yes, i'm casting them to what's supposed to be the correct class).

Here's my query:
List list = session.find("from com.xxx.xxx.bizmodel.survey.UserAnswerImpl as userAnswer inner join userAnswer.answer as answer inner join answer.question as question inner join question.survey as survey where survey.id = ?", new Long(aSurveyId), new LongType());

The cast to UserAnswer whcih UserAnswerImpl implements is failing. What in the world am I doing wrong here?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 1:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Please post the code if we need to help ya', ok ? ;)


And secondly without even looking at the query I would like you try to e.g. print the type of the elements in the result you get from find - then you might see that it is possible an Object[], meaning it returns more than one item per row.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 1:20 pm 
Newbie

Joined: Wed Oct 29, 2003 10:47 am
Posts: 7
Location: Waukesha, WI
Thanks for the help... I was indeed getting Object[] back from my query because I wasn't using "select" in my query.


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.