-->
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.  [ 4 posts ] 
Author Message
 Post subject: Syntax for getting whole collections from a projection query
PostPosted: Thu Dec 01, 2005 6:15 pm 
Newbie

Joined: Tue Sep 30, 2003 2:00 pm
Posts: 11
Please forgive me if this is an obvious question...

I'm having trouble getting an entire collection from a mapped class as a collection (not the individual elements). I cannot figure out the syntax (if it is possible).

The reason I want to do this is because I would like to dynamically instantiate a 'view' class inside a query, with one of the arguments to the constructor being a Set from my mapped class.

My hibernate version is 2.1.7

Here is roughly my class mapping:

Code:
<class name="MyBigClass">

   <id name="id" .../>


   <set name="mySet" cascade="all">
         <key column="big_class_id"/>
         <composite-element class="MySetObject">
             <property name="itemOne" .../>
             <property name="itemTwo" .../>
         </composite-element>
   </set>

   ...
   <some-other-stuff/>

</class>


my "view" class constructor looks like this:

Code:
MyViewObject(String id, Set mySet)



if I try this query

Code:
   select new MyViewObject(item.id, item.mySet) from MyBigClass item


it fails with an exception saying "expecting 'elements' or 'indices' after: id"

But the elements are not what I want, I want the whole set as a set.

Is there any way to do this? What would the syntax be?

(calling the query with elements(item.mySet) is not what I want - that would return a join with each of the MySetObject objects individually. I want the whole set).

I have looked through "Hibernate in Action" and searched, I can't find anything like this.

Thank you.

Hibernate version:
2.1.7

Mapping documents:
see above

Code between sessionFactory.openSession() and session.close():
see above

Full stack trace of any exception that occurs:

not relevant, I am asking about syntax

Name and version of the database you are using:

sybase ASE 15

The generated SQL (show_sql=true):

not relevant, I am asking about syntax

Debug level Hibernate log excerpt:

not relevant, I am asking about syntax[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:41 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Does Hibernate 2.1.7 support the constructor syntax?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 10:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
what you are trying is not possible


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 5:37 pm 
Newbie

Joined: Tue Sep 30, 2003 2:00 pm
Posts: 11
joshua wrote:
Does Hibernate 2.1.7 support the constructor syntax?


yes.


steve wrote:
what you are trying is not possible


ok, thanks. I'll just build sets from the results given by elements()


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