-->
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.  [ 2 posts ] 
Author Message
 Post subject: Select item.name from Item as item..doesnt return object
PostPosted: Wed May 12, 2004 12:35 pm 
Newbie

Joined: Sat Apr 03, 2004 6:36 pm
Posts: 5
Hi,

I am new to hibernate. I want to load all the instances of an object which has some one to one relation. I dont want to load this relations when I fire select query.

I am using "Select item.name,item.desc from Item as item" as the query. I just want to retrieve name and description of the items. But query.list() doesnt return Item objects instead it seems to be returning Object[].

Am I missing anything here. How can I browse thru the list I am getting.

UMAR


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 12:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the documentation, "Hibernate query language". You are using projection ("select foo, bar, ..."), so you get an arrays of objects back. Index zero is "foo", index one is "bar", and so on. If you need "foo", then query only "foo".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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