-->
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.  [ 4 posts ] 
Author Message
 Post subject: query list casting help needed
PostPosted: Thu Aug 07, 2008 11:00 pm 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
I'm using
Code:
...
Query q =  (Query) getSession().createSQLQuery(query);
return q.list();


This is returning a Long "id" column and a Float "distance" column.

I'm getting a casting exception when trying to get the results from that list. How can i get at the id of lets say index 2? What should i cast this list object as?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 4:16 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
I am not very sure what you are asking for but I guess you are asking for casting to get a rows from a result set having multiple columns

int cntr = 0;
Object[] objArr = (Object[])resultList.get(cntr);
Long id = (Long)objArr[0];
Float distance = (Float)objArr[1];

_________________
Please rate this post if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 4:16 am 
Beginner
Beginner

Joined: Wed Jul 09, 2008 5:34 am
Posts: 41
Location: Brno, Czech Republic
What is the query you are using?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 10:30 am 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
thanks sethrohit, that worked..
turns out the long id came back as a BigInteger.


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