I have a Points Object with a property of Map<Round, Integer>. Everything worked fine! I then decided to swap this for a TreeMap so that all Points records were sorted by the Round key. Implemented Round with Comparable Interface as part of this. I'm getting an Illegal Argument Exception error:
Can not set java.util.TreeMap field to org.hibernate.collection.spi.PersistentSortedMap
I can't see what the issue is - any clues?
Field:
private TreeMap<Round, Integer> points;
Constructor:
this.points = new TreeMap<>();
Setter:
public void setPoints(TreeMap<Round, Integer> points) {
this.points = points;
}
Refer to collections-semantics
You should use interface
Map(if sorting doesn't matter)/SortedMapinstead of implementationTreeMapwhen defining your field.i.e.