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.
|