Yes thats what I found out debugging. The ProxyConverter will unwrap the proxy prior to calling the ReflectionConverter. So we can easily leave it out of the discussion.
Von: Jaime Metcher [mailto:[email protected]] Gesendet: Donnerstag, 18. Oktober 2012 10:24 An: [email protected] Betreff: Re: [xstream-user] Re: AW: Hibernate associations Jörg, I think you've lost me there. Can you elaborate a bit? I'm not sure why you want to call super.marshal every time you see a new entity. Also, my recollection is that you don't need to worry about the HibernateProxyConverter as registering it with high priority means it will already have done its job and gotten out of the way. Or maybe that changed in 1.4? I really do need to upgrade... Jaime On Thu, Oct 18, 2012 at 5:42 PM, Jörg Schaible <[email protected]> wrote: You might try to adjust your approach slightly by keeping track of the already converted objects: ============== %< ============== class EntityExternalRefExportConverter extends ReflectionConverter { public boolean canConvert(final Class p_clazz) { return BaseEntity.class.isAssignableFrom(p_clazz); } public void marshal(final Object p_object, final HierarchicalStreamWriter p_writer, final MarshallingContext p_context) { Set<Id> tracker = (Set<Id>)p_context.get("ID_TRACKER"); if (tracker == null) { p_context.put("ID_TRACKER", tracker = new HashSet<Id>()) } Id id = ((BaseEntity) p_object).getId(); if (tracker.add(id)) { super.marshal(p_object, p_writer, p_context); } else { p_writer.setValue(id); } } ============== %< ============== I think you get the idea. The code *assumes* that the object would normally be handled by the ReflectionConverter, but it might be the HibernateProxyConverter instead. You have to derive from the appropriate converter. Cheers, Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
