Enhancement 238 : ENHANCEMENT - Automatically convert a fetch join to a query join for *ToMany joins and LIMIT OFFSET
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.5.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
09/03/2010
Updated 
09/03/2010
Type 
Enhancement
 
Attachments 
No attachments

When a query uses setMaxRows etc it can't support fetch joins to *ToMany properties.

Currently those *ToMany joins are removed. We should now convert them over to query joins instead.

Query<Customer> query = Ebean.find(Customer.class)
    // this will automatically get converted to a
    // query join ... due to the maxRows
    .join("contacts")//, new JoinConfig().query())
    .setMaxRows(5);

List<Customer> list = query.findList();
 
Rob 09 Mar 23:06
Now will produce 2 queries ...
<sql summary='Customer' >
select c.id c0, c.status c1, c.name c2, c.smallnote c3, c.anniversary c4, c.cretime c5, c.updtime c6, c.billing_address_id c7, c.shipping_address_id c8 
from o_customer c 
limit 6
</sql>
<sql mode='+query' summary='Customer +many:contacts' load='path:contacts batch:100 actual:3' >
select c.id c0
        , cc.id c1, cc.first_name c2, cc.last_name c3, cc.phone c4, cc.mobile c5, cc.email c6, cc.cretime c7, cc.updtime c8, cc.customer_id c9 
from o_customer c
left outer join contact cc on cc.customer_id = c.id  
where c.id in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
order by c.id
</sql>

So there is a separate SQL query ... for the query join.

Rob 11 Mar 23:42
Fixed in HEAD

Fixed in HEAD.

woResponse

Upload a file