Hello,
I have problem with
one-to-many relationships.
Situation: I have a table and class called "
orders" and a lot of
order items, which are related with orders using a foreign key. The class orders has got a collection with all order items.
What I want to do:Now I want to load a specific order via an order number (primary key). Usually the collection of order items is filled with ALL order items.
But I don't want that. I want the collection to be filled only with order items of a special amount. So I want to limit the loading of the one-to-many relationship.
Normally this is no good idea (what, if I save the order?), but this is read-only. And I only want to perform
one single query.
Does anyone have an idea how to do this?
The classes are something like this
Code:
public class Order {
private Long orderId;
private Date date;
private Set<OrderItem> orderItems;
//...
}
public class OrderItem {
private Double amount;
private String itemText;
// ...
}