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]