Steve Ebersole commented on Task HHH-8164

Some other options:

  1. Re-purpose @Sort to simply define that we want the set/map to be sorted. A comparator to apply could be broken out into a separate annotation. @Comparator? @SortComparator? If that companion annotation was not present, @Sort would indicate a natural sort.
  2. Distinct annotations, as mentioned in subject. @NaturalSort and @ComparatorSort. Although Emmanuel mentioned that it might be better to use @SortNaturally and @SortByComparator because of auto-completion in Eclipse not supporting middle-matching the way IntelliJ does.

Personally I prefer the first approach:

public @interface Sort {
}

public @interface SortComparator {
    Class<? extends Comparator> value();
}

@Entity
public class Order {
    ...
    @OneToMany( mappedBy="order" )
    @Sort
    @SortComparator( OrderLineItemNumberComparator.class )
    public SortedSet<LineItem> getLineItems();
}

public class OrderLineItemNumberComparator implements Comparator<LineItem> {
    ...
}
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira