Hi Jörg, The Hibernate PersistentSortedSet needs a SessionImplementor, which I hide in lower layer API, so I instead opted to use "order-by" in hbm.xml, and my POJO uses a LinkedHashSet, that combination works (db sort should be faster as well). (I tried modifying the TreeSetConverter and TreeMapConverter to get around the "comparator" tag, but without success. Since I have one way that works, I'll just leave it at that.) - amit.
> To: user@xstream.codehaus.org > From: joerg.schai...@gmx.de > Date: Thu, 27 Nov 2014 22:11:28 +0100 > Subject: [xstream-user] Re: specifying the comparator for TreeSetConverter > > Hi Amit, > > sorry for the late response. > > Amit Basu wrote: > > > I get com.thoughtworks.xstream.mapper.CannotResolveClassException: > > comparator in > > > com.thoughtworks.xstream.converters.collections.TreeSetConverter.unmarshal(TreeSetConverter.java:86) > > I am using a SortedSet with TreeSet impl and hibernate mapping file has > > <set name ="groups" .... table="..." sort="com....MyComparator", etc to > > me, it seems XStream's TreeSetConverter is not getting my comparator class > > from the hbm.xml, and complaints that "comparator" class is not there. If > > I switch to Set and HashSet, there is no issue, but then I'd have to > > implement the sorting at a higher layer. > > I am not sure what you try to accomplish. Any Hibernate support in XStream > is one-way only i.e. you can marshal a Hibernate PersistentSortedSet and you > will get a TreeSet at unmarshalling time. > > Note, that I have absolutely no Hibernate experience, so I don't know what > you can do with the Hibernate mapping files. All test code in Xstream was > provided by helpful users. > > As far as XStream is concerned, the PersistentSortedSet is handled by the > HibernateSortedSetConverter which is derived from the TreeSetConverter. That > one will marshal also the comparator that is returned by > SortedSet.comparator(). > > So how does the XML for this comparator looks like that has been produced by > XStream? What do you exactly mean with "complaints"? > > Cheers, > Jörg > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > >