From: <leg...@at...> - 2004-03-23 15:56:46
|
The following issue has been updated: Updater: Mark Rohan (mailto:mr...@ci...) Date: Tue, 23 Mar 2004 9:56 AM Comment: The previous solution is only halfway there. It provides ordering for aliased related objects, but it doesn't do for subcriteria instances. I've attached a solution which handles both of the following cases: // Alias example Criteria fooCriteria = session.createCriteria(Foo.class); fooCriteria.createAlias("blah", "blahAlias"); fooCriteria.addOrder(Order.asc("blahAlias.property")); // Subcriteria example Criteria barCriteria = criteria.createCriteria("bar"); // Subcriteria barCriteria.addOrder(Order.asc("barProperty")); This solution will also work for aliased properties of subcriteria instances. Here is a summary of the changes (all changes are noted in the modified source files, which are included in the .zip file). The changes were made to the latest 2.1.2 release: net.sf.hibernate.expression.Order --------------------------------- Added method: public String getPropertyName() Added method: public boolean isAscending() net.sf.hibernate.impl.CriteriaImpl ---------------------------------- Modified method: Subcriteria.public Criteria addOrder(Order) Modified method: public Criteria addOrder(Order) Added method: private void addOrder(String, Order) Added inner class: public static final class OrderingEntry net.sf.hibernate.loader.CriteriaLoader -------------------------------------- Modified constructor Changes: Attachment changed to hibernate-2.1.2-with-order.zip --------------------------------------------------------------------- For a full history of the issue, see: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-132&page=history --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-132 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-132 Summary: Order support for joined Criteria Type: Improvement Status: Unassigned Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: Hibernate2 Components: core Versions: 2.1 Assignee: Reporter: Grzegorz Mucha Created: Thu, 12 Jun 2003 3:59 AM Updated: Tue, 23 Mar 2004 9:56 AM Description: Is there a plan to add some extensions to Criteria API? Since there is now FETCH support in Criteria, a nice thing would be to allow users sorting the criteria returned not only by class properties, but the associated classes' properties as well. example: class Task { User user; ........ } Criteria crit=session.createCriteria(Task.class); crit.addOrder(Order.asc("user.lastName"); I know it can be done in java,by applying own sorters for the returned list, though I'd prefer a single step process --------------------------------------------------------------------- JIRA INFORMATION: 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.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |