FYI:
In HEAD is code to support ENH-171 and ENH-172.
These enable you to control/specify the lazy loading queries.
Example:
- Query<Order> query = Ebean.find(Order.class)
- .join("customer","+lazy(10) name, status")
- .join("customer.contacts");
This becomes...
- Find Orders...
- Lazy load customers 10 at a time...
- the lazy load query is:
find customer (name, status)
join contacts where id in (?,?,?,?,?,?,?,?,?,?)
Note that instead of using the +lazy(10) hint... you could use JoinConfig and write:
.join("customer","name, status", new JoinConfig().lazy(10))
In Addition to controlling the lazy loading query we can specify a "query join"
... which means fetch this part of the object graph using a second query.
That is, instead of building the object graph using 1 query (and then lazy loading) we can specify to use multiple queries (and then use lazy loading). Note that it can be more efficient to use multiple queries in some cases (such as when you have multiple OneToMany relationships to load - aka to avoid a cartesian product).
- List<Order> list = Ebean.find(Order.class)
- .join("customer", new JoinConfig().query(3).lazy(10))
- .findList();
Find Orders
.. then immedidately Load the first 3 customers referenced by those orders
.. after that lazy load customers 10 at a time as needed
Anyway, that's in HEAD for those that want to play.
Cheers, Rob.