Hi.
I have two related objects, Account and LineItem. See end of this post for hibernate mapping data. In "view" type situations I would like to sort the LineItems associated with an account. I would like the user to control the column used for sorting so this sorting must be at run-time, preferably at the database.
I can succesfully sort LineItems at runtime using both HQL and Criteria, however I can only receive a new List of LineItems using this approach. I would like to receive the sorted data within the existing Object graph, that is as an updated collection in an Account object. Is this possible?
Code:
<class name="Account" table="FINANCE_ACCOUNTS">
<id name="accountID">
<generator class="increment"/>
</id>
<property name="name"/>
<property name="type" type="accountType"/>
<set name="lineItems">
<key column="accountId"/>
<one-to-many class="LineItem"/>
</set>
<many-to-one name="user" column="userid"/>
</class>
<class name="LineItem" table="FINANCE_LINEITEM">
<id name="lineItemId">
<generator class="increment"/>
</id>
<property name="description"/>
<property name="amount"/>
<property name="postingDate"/>
<many-to-one name="account" column="accountId"/>
</class>
Many thanks for any help given.