Hi Michael,

Michael Teixeira wrote:

> As part of going from xstream 1.3.1 to xstream 1.4.2, I'm trying to make
> use of HibernateProxyConverter.
> 
> So I've changed the xstream configuration from, in 1.3.1:
> 
>          this.xstream = new XStream();
>         xstream.registerConverter(new
> JavaBeanConverter(xstream.getMapper()), XStream.PRIORITY_VERY_LOW);
>         Mapper mapper = xstream.getMapper();
>         xstream.registerConverter(new
>         HibernateCollectionConverter(mapper));
>         xstream.addDefaultImplementation(java.util.ArrayList.class,
> org.hibernate.collection.PersistentList.class);
>         xstream.addDefaultImplementation(java.util.HashMap.class,
> org.hibernate.collection.PersistentMap.class);
>         xstream.addDefaultImplementation(java.util.HashSet.class,
> org.hibernate.collection.PersistentSet.class);
>         xstream.addDefaultImplementation(java.util.ArrayList.class,
> org.hibernate.collection.PersistentBag.class);
>         xstream.alias("java.util.ArrayList",
> org.hibernate.collection.PersistentBag.class);
> 
> to, in 1.4.2:
> 
>         xstream = new XStream() {
>             protected MapperWrapper wrapMapper(final MapperWrapper next) {
>                 return new HibernateMapper(next);
>             }
>         };
>         xstream.registerConverter(new HibernateProxyConverter());
>         xstream.registerConverter(new
> HibernatePersistentCollectionConverter(xstream.getMapper()));
>         xstream.registerConverter(new
> HibernatePersistentMapConverter(xstream.getMapper()));
>         xstream.registerConverter(new
> HibernatePersistentSortedMapConverter(xstream.getMapper()));
>         xstream.registerConverter(new
> HibernatePersistentSortedSetConverter(xstream.getMapper()));
> 
> That more or less seems to work, with this exception:
> 
> I have a java class that represents a relational table that is being
> serialized by xstream.  But this class has some transient properties along
> with the usual persistent properties that map to database columns.
> 
> Some of these transient properties are also java classes that I've
> defined.
>  Something simple like a class that holds a name and value with a getter
> and setter.
> 
> In my prior code, using xstream 1.3.1 and JavaBeanConverter, these
> contained class instances were serialized and deserialized without issue.
>  In the 1.4.2 code, though, these properties are not serialized, they are
> omitted.
> 
> So it would seem that HibernateProxyConverter does not handle these.
> 
> I've been trying, without success, to add a second converter to handle
> these.  I'm not sure that's the correct approach, though.  In general, I
> could use some help, or guidance, on how best to do this.

The JavaBeanConverter is not related in any way to the 
HibernateProxyConverter. The latter only handles the proxy itself, not the 
real instance. If you have registered JavaBeanConverter before, you should 
register it now in the same way.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to