-->
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.  [ 5 posts ] 
Author Message
 Post subject: Selecting a couple of columns
PostPosted: Thu Mar 17, 2005 7:56 am 
Newbie

Joined: Thu Mar 17, 2005 7:50 am
Posts: 8
Location: Tunis
Hibernate version: 2.1.7

Hi all!!
I'm new to hibernate, and i would know if it is possible to select a couple of columns and retrieve the resuts in a list of beans.
Thanks.
Walid.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 8:31 am 
Newbie

Joined: Wed Mar 09, 2005 5:03 am
Posts: 7
Selecting a couple of columns, just use HSQL:
Code:
Select object.column1, object.column2 from MyClass object


Returns an array of objects.

mappings:
Code:
<class name="MyClass" .. >
....
<property name="column1"..../>
<property name="column2"..../>
....
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 8:57 am 
Newbie

Joined: Thu Mar 17, 2005 7:50 am
Posts: 8
Location: Tunis
Hi Jacob,
thank you for your answer, but i would like the list returned to be composed of elements of type MyClass.
Walid.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 9:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
select new MyClass(object.column1, object.column2) from MyClass object

will return MyClass objects as long as it has a constructor matching the specified properties.

note that these MyClass objects are not entities, but mere half-full value objects.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 11:46 am 
Newbie

Joined: Thu Mar 17, 2005 7:50 am
Posts: 8
Location: Tunis
Works Fine !!!
Great, thanks.


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