Hibernate version:3.1
I am trying to execute HQL, so that the results are ordered by a property of an object in a set. The object model looks like this: Ad contains ContentFile contains a set of ContentFileDetails
where ContentFileDetails has a property called size. I want to order the query by the size property.
my HQL ends up looking like this (but i can't figure out what to put where the ???? is.)
Code:
from Ad ad LEFT JOIN FETCH ad.contentFile c LEFT JOIN FETCH c.detailSet d order by ???? asc
I have tried d.size and elements(d).size, but those don't seem to work.
My mapping snips look like this:
Code:
<class name="ContentFile" table="UPLOADED_FILES">
....other props
<set name="detailSet" inverse="true">
<key column="UPLOADED_FILES_ID"/>
<one-to-many class="ContentFileDetails" />
</set>
</class>
<class name="ContentFileDetails" table="UPLOADED_FILES_VERSION" lazy="true">
......other propsother props
<many-to-one name="file" outer-join="true"
class="ContentFile" column="UPLOADED_FILES_Id" not- <property name="size" column="Size" type="java.lang.Long" />
</class>
Any help would be greatly appreciated!!!