-->
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: Get string values from two combined objects
PostPosted: Mon Nov 08, 2010 10:14 pm 
Newbie

Joined: Fri Jul 16, 2010 8:20 am
Posts: 4
Hi,

I am using a HQL with getHibernateTemplate().find to get some values from two tables. The following is my code.

Code:
public List findValues(String username, String carmodel) {
     return getHibernateTemplate().find("from profile p, car c where p.name='"+username+"' and c.model='"+carmodel+"' and c.user=p.user");
}



I am able to get the correct numbers of objects return. However, when I tried to get the string values inside the object, I got values like [Ljava.lang.Object;@1a2b5ca, [Ljava.lang.Object;@14ce4b0, [Ljava.lang.Object;@13a056f .. etc...

Is there a way to get the string value of my car and profile object?

Thanks.


Top
 Profile  
 
 Post subject: Re: Get string values from two combined objects
PostPosted: Tue Nov 09, 2010 9:35 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
The hibernate returns list of arrays to you. Use "result[0]" to get a profile and "result[1]" to get a car.


Top
 Profile  
 
 Post subject: Re: Get string values from two combined objects
PostPosted: Tue Nov 09, 2010 10:51 pm 
Newbie

Joined: Fri Jul 16, 2010 8:20 am
Posts: 4
Thank you for helping me to solve my problem.


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.