hibernate order by association

Posted by Gary Kephart on Stack Overflow See other posts from Stack Overflow or by Gary Kephart
Published on 2009-05-15T17:49:37Z Indexed on 2010/04/19 20:13 UTC
Read the original article Hit count: 334

Filed under:
|
|

I'm using Hibernate 3.2, and using criteria to build a query. I'd like to add and "order by" for a many-to-one association, but I don't see how that can be done. The Hibernate query would end up looking like this, I guess:

select t1.a, t1.b, t1.c, t2.dd, t2.ee
from t1
inner join t2 on t1.a = t2.aa
order by t2.dd   <-- need to add this

I've tried criteria.addOrder("assnName.propertyName") but it doesn't work. I know it can be done for normal properties. Am I missing something?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about order-by