Bug 206 : Problems parsing @OrderBy configuration
Priority 
High
Reported Version 
 
Logged By 
imario
Status 
Fixed
Fixed Version 
2.4.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
13/01/2010
Updated 
13/01/2010
Type 
Bug
 
Attachments 
No attachments

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.

 
Rob 14 Jan 09:12
Fixed in HEAD

Found and fixed by Mario.

Issue with the parsing of the OrderBy .. needed to take into account multiple columns with appropriate table alias.

woResponse

Upload a file