I seem to recall that the @Transient annotation is used by XStream to mark
properties to be omitted.  Obviously it's a JPA annotation as well.  But
I'm not sure that this is something new in 1.4.2

Jaime

On Wed, May 9, 2012 at 5:41 AM, Michael Teixeira <
[email protected]> 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.
>
> Thanks,
> Michael
>
>

Reply via email to