See Mario's test case of MainAutoQueryTune1
private void tuneJoin() { List<Order> list = Ebean.find(Order.class) .setAutofetch(true) .join("customer") .where() .eq("status", Order.Status.NEW) .eq("customer.name", "Rob") .order().asc("id") .findList(); for (Order order : list) { System.out.println(order.getId() + " " + order.getOrderDate()); } }
The issue here was in SqlTreeBuilder ... specifically at the point of the IncludesDistiller ... where it determines extra joins required for the WHERE and ORDER BY clauses.
It was using a different check to see if a particular join/include had already been included in the query (it was just checking for not null).
Fixed by collecting all the actual joins included by the select (so as to bypass checking for (no property joins) which was the problem.
Fixed in HEAD.