Monday, April 2, 2012

org.hibernate.AnnotationException: A sorted collection has to define @Sort:


org.hibernate.AnnotationException: A sorted collection has to define @Sort: model.ItemSortedMap.images
at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:446)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1979)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at util.SessionUtil.<clinit>(SessionUtil.java:10)
... 1 more


Reason: I used SortedMap as the property type. But does not annotate using @Sort annotation:

Solution: Add @Sort annotation or change the property type from SortedMap to Map.

No comments:

Post a Comment