-->
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: [Beginner] Use the result of session.find()
PostPosted: Tue Feb 03, 2004 10:27 am 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hello,

Please excuse me for this silly question but how do you use the result of a find() ?
It returns a List but how to cast each element of the result.

If you have a query like :

Code:
List result = sess.find( "select cat.name, dog.name from Cat as cat, Dog as dog where cat.age = dog.age" );


How do I do then to use cat.name and dog.name ??

Thanks,
sylvain_2020


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 10:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Object[] rowOne = result.get(0);
String catName = rowOne[0];
String dogName = rowOne[1];


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 3:16 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Assuming cat.name and dog.name refer to java.lang.String properties:
Code:
Object[] rowOne = result.get(0);
String catName = (String)rowOne[0];
String dogName = (String)rowOne[1];


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.