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 filter the LineItems associated with an account by date (for example, LineItems between 01/01/2000 and 01/02/2000).
I have tried various methods using both HQL and Criteria. I can succesfully filter the LineItems, however I can only get the LineItems back as a new List, not as an update collection within a populate Account object. Is it possible to filter an association in place?
Just to make it clear, my full data set could be as follows:
Account.name=Account1
Account.type=Savings
Account.lineItem.1.description=Cash
Account.lineItem.1.postingDate=01/01/2000
Account.lineItem.2.description=Food
Account.lineItem.2.postingDate=05/01/2000
Account.lineItem.3.description=Books
Account.lineItem.3.postingDate=01/02/2000
for my view I would like to receive an Account that only has LineItems between 01/01/2000 and 01/02/2000 (even thought the database has more LineItems).
Account.name=Account1
Account.type=Savings
Account.lineItem.1.description=Cash
Account.lineItem.1.postingDate=01/01/2000
Account.lineItem.2.description=Food
Account.lineItem.2.postingDate=05/01/2000
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" order-by="postingDate desc">
<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.