Hi
I'm trying to use TreeSet but getting NPE on the compareTo() method when it does a find():
at com.objectdb.o.LDR.z(LDR.java:269) at com.objectdb.o.OBC.aP(OBC.java:1058) at com.objectdb.o.OBC.aN(OBC.java:976) at com.objectdb.jpa.EMImpl.find(EMImpl.java:625) ... 123 more Caused by: java.lang.NullPointerException at java.lang.String$CaseInsensitiveComparator.compare(String.java:1192) at java.lang.String$CaseInsensitiveComparator.compare(String.java:1186) at com.rpm.model.DropdownValue.compareTo(DropdownValue.java:58) at com.rpm.model.DropdownValue.compareTo(DropdownValue.java:9) at java.util.TreeMap.compare(TreeMap.java:1290) at java.util.TreeMap.put(TreeMap.java:538) at java.util.TreeSet.add(TreeSet.java:255) at objectdb.java.util.TreeSet.add(Unknown Source) at java.util.AbstractCollection.addAll(AbstractCollection.java:344) at java.util.TreeSet.addAll(TreeSet.java:312) at objectdb.java.util.TreeSet.addAll(Unknown Source) at java.util.TreeSet.<init>(TreeSet.java:160) at objectdb.java.util.TreeSet.<init>(Unknown Source) at objectdb.java.util.TreeSet.__odbNewInstanceWithData(Unknown Source) at com.objectdb.o.CLT.readStrictly(CLT.java:226) at com.objectdb.o.MUT.readAndAdjust(MUT.java:500) at com.objectdb.o.UMR$S.C(UMR.java:1015) at com.objectdb.o.UMR.B(UMR.java:603) ... 138 more
My compareTo() method looks like this:
@Override public int compareTo(DropdownValue ddv) { return String.CASE_INSENSITIVE_ORDER.compare(dropdownValue, ddv.dropdownValue); }
The dropdownValue's are accessed through a collection field in another class that uses eager fetch:
@OneToMany(fetch = FetchType.EAGER) private Set<DropdownValue> dropdownValues = new TreeSet<>();
I presume the NPE is either on the 'dropdownValue' or 'ddv' variable. Any ideas how to sort this please?
Thanks Russ