[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2629?page=c...
]
Jörg Heinicke updated HHH-2629:
-------------------------------
Attachment: CriteriaQueryTranslator.java.patch.txt
Enable ordering by association paths
------------------------------------
Key: HHH-2629
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2629
Project: Hibernate3
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