This enhancement is to add explicit control over lazy loading queries.- control the batch size to load many beans or collections at a time- control the properties to load- additionally specify joins to include in the lazy load query
+lazy
Example using +lazy on a join
Query<Order> query = Ebean.find(Order.class) .select("status") .join("customer","+lazy(10) name, status") .join("customer.contacts"); List<Order> list = query.findList();
The 'root' query will fetch orders.
If you invoke lazy loading on the customer it will lazy load 10 customers at a time, selecting the name and status properties and joining the contacts for that customer.
The lazy loading query would be:
find customer (name, status) join contacts where id in (?,?,?,?,?,?,?,?,?,?)
Note: In this case the customer.contacts join is put into the lazy load query as its parent is "customer".
Note: that if the lazy loading was invoked by trying to access a property other than the customer name or status then all the customer properties will be included in the select.
Note this is a Duplicate of #172