Hi!
If add
@OrderBy("id asc, orderQty asc")
to the "OrderDetail details" assoc in com.avaje.tests.model.basic.Order the test e.g. TestBatchLazy fails with an invalid sql.
The invalid sql looks like this:
select o.id c0
, od.id c1, od.order_qty c2, od.ship_qty c3, od.unit_price c4, od.cretime c5, od.updtime c6, od.order_id c7, od.product_id c8
from o_order o
left outer join o_order_detail od on od.order_id = o.id
where o.id = ?
order by o.id , od.id asc, orderQty asc
As you can see in the sql "order by" clause the "id" has been added twice (which works but is not necessary) and the "orderQty" field of the associated entity has not been correctly parsed to "od.order_qty".
The awaited sql string of the order by is
order by od.id asc, od.order_qty asc
I've tried to debug this thing down, but faild in BeanPropertyAssocMany where the @OrderBy string (fetchOrderBy) is used to configure the query. It is clear to me that now ebean can not know that the @OrderBy string is used to just lookup fields of the child entity - it makes no sense to take the field-list of the "base entity" into account as those values can not change e.g if used in an composite key.