-->
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: Howto query keys only
PostPosted: Wed Sep 15, 2004 9:55 am 
Beginner
Beginner

Joined: Wed Feb 11, 2004 6:08 am
Posts: 29
Location: Germany
Is there a way (in v2.1) to only query a list of the mapped keys without the full objects?
I know its possible do a query.iterate(), but this seems to works only within session scope.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 15, 2004 11:09 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Hello Dirk,

You can always select on the attribute of your object. I.e: Select object.id From MyObject object;
This should return a list with your keys.
When you select on multiple values a list of Object[] is returned, where Object[].length is equal to the attributes you selected.
I.e.: select object.id, object.name from MyObject as object; returns a list with Object[] instances where Object[0] = id and Object[1] = name.
Another nice way of selecting a subset of your attributes, but retrieve an object instance is like this:
select new MyObject(object.id,object.name) from MyObject object;

Hope this will help.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 16, 2004 3:28 am 
Beginner
Beginner

Joined: Wed Feb 11, 2004 6:08 am
Posts: 29
Location: Germany
Hi Dencel,

thanks for your reply; your hint works great :-)

Dirk


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.