Uploaded image for project: 'Hibernate ORM'
  1. HHH-8827

@SortNatural and @SortComparator not working.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.0.Final
    • Fix Version/s: 4.3.1
    • Component/s: hibernate-core
    • Labels:
    • Environment:
      JPA 2.1, Glassfish 4.
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      When using the @SortNatural annotation, the application fails with the exception:

      Caused by: org.hibernate.AnnotationException: A sorted collection must define and ordering or sorting : com.doblones.data.StockSummarySegment.summaries
      at org.hibernate.cfg.annotations.CollectionBinder.applySortingAndOrdering(CollectionBinder.java:603)
      at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:447)
      at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2027)
      at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:834)
      at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:753)
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3762)
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3716)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
      ... 53 more

      Code is:

      @OneToMany(mappedBy = "segment", fetch = FetchType.EAGER, cascade =

      {CascadeType.ALL}

      )
      @SortNatural
      private SortedSet<StockSummary> summaries;

      If I revert to the deprecated @Sort annotation, it works fine.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: