michael wrote:
No. In Hibernate3 you could use filters
Since Hibernate3 is in alpha, I will stay with 2.1 for now. I found a solution for my problem, though not sure if it's the best one. Instead of mapping getLineItems() to LineItem, getLineItemsLazy() is used. The business method is defined as follows,
Code:
Order findOrder(long orderNo, int itemNo) {
Order order = session.find.....
if (itemNo == ALL_LINE_ITEMS) {
Set set = order.getLineItemsLazy();
set.size();
order.setLineItems(set);
} else {
order.setLineItems(new HashSet(session.filter(order.getLineItemsLazy(), "where this.itemNo=" + itemNo)));
}
return order;
}