google app engine - HashSet turning into TreeSet when unit testing JDO GAE/J app in maven -
i have java app gae uses maven (the net.kindleit version) following classes:
public class c1 { ... @persistent(mappedby = "c1") @element(dependent = "true") private set<c2> c2s = new hashset<c2>(); public set<c2> getc2s() { return this.c2s; } ''' } public class c2 { private c1 c1; ... more properties, getters , setters ... }
in 1 of tests, executing following:
c2 myc2 = new c2(myc1); myc1.getc2s().add(myc2);
the unit test works running inside eclipse, , code works in production app, when run unit tests under maven, test fails following:
java.lang.classcastexception: com.me.model.c2 cannot cast java.lang.comparable @ java.util.treemap.compare(treemap.java:1188) @ java.util.treemap.put(treemap.java:531) @ java.util.treeset.add(treeset.java:255) @ com.me.service.c2serviceimpl.createc2(c2serviceimpl.java:319)
i understand exception, c2 not implement comparable, , required insert things treeset, question is, why returning set backed treeset, , not hashset.
Comments
Post a Comment