Enhancement 170 : ENHANCEMENT: Have control over lazy loading (batch size, select and joins)
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.2.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
30/10/2009
Updated 
30/10/2009
Type 
Enhancement
 
Attachments 
No attachments

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

 
Rob 30 Oct 12:09
Example using +lazy on a join

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.

Rob 02 Nov 12:10
Duplicate of #172

Note this is a Duplicate of #172

woResponse

Upload a file