开发者

unexpected sublist result returned by Hibernate query

I hava a HQL query as the following which returns a java.util.RandomAccessSubList of ORDER. The offset of the SubList is 1,so the first element of the query result list can't be accessed.

SELECT vendor.order FROM OrderVendor vendor WHERE vendor.user.id=? ORDER BY vendor.order.creationTime desc

select order1_.order_id as order1_18_,(..... other fields....) 
from ORDER_VENDOR ordervendo0_ 
inner join ORDER order1_ on ordervendo0_.order_id=order1_.order_id, 
where ordervendo0_.user_id=? 
order by order1_.creationTime desc

I tried another way.First get a List of OrderVendor, then use the the method OrderVendor.getOrder() to access the order.But is's a little fussy!

FROM OrderVendor vendor WHERE vendor.user.id=? ORDER BY vendor.order.creationTime desc

select ordervendo0_.vendor_id as vendor1_20_ (....other fields...) 
from ORDER_VENDOR ordervendo0_, 
ORDER order2_ 
where ordervendo0_.ord开发者_如何学JAVAer_id=order2_.order_id 
and ordervendo0_.user_id=? 
order by order2_.creationTime desc limit ?

My question is why the first query return a SubList and Why the offset of the SubList is 1 ?

Thanks !

Geln

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜