[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2629?page=c...
]
Nick Armstrong commented on HHH-2629:
-------------------------------------
Does anybody know if this will be fixed soon?
I'm using a variation of John's solution at the moment but would rather not have
that in the code when we move the application to production.
Enable ordering by association paths
------------------------------------
Key: HHH-2629
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2629
Project: Hibernate Core
Issue Type: Patch
Components: query-criteria
Affects Versions: 3.2.4.sp1
Reporter: Jörg Heinicke
Attachments: CriteriaQueryTranslator.java.patch.txt
In Hibernate's criteria API ordering is not possible on association properties
without explicitly creating aliases.
This also only works on one level, not recursively as it would be needed in the following
example.
Criteria criteria = session.createCriteria(Account.class);
Criteria pCriteria = criteria.createCriteria("person");
pCriteria.add(Example.create(person));
pCriteria.createCriteria("company");
criteria.addOrder(Order.asc("person.company.name"));
return criteria.list();
I have changed CriteriaQueryTranslator in a way that it first searches the
aliasCriteriaMap, second the associationPathCriteriaMap. And the key used for the search
is no longer
StringHelper.root( propertyName );
but
StringHelper.qualifier( propertyName );
From what I understand this can't break anything since it has always only worked with
one '.' in the path. For those cases the key stays the same.
This implementation is still not perfect since
1. you need to create criteria in advance
2. you can't switch between alias and actual association path. The best would
probably be to walk the path recursively.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira