How to use fromXML() without using the ReflectionConverter

View: New views
4 Messages — Rating Filter:   Alert me  

How to use fromXML() without using the ReflectionConverter

by cmathrusse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm attempting to use the fromXML(String, Object) method to update my target object, which happens to be a JPA entity. The issue that I'm having is that XStream uses the ReflectionConverter to assign the new values directly to the fields. This works just fine but EclipseLink, my JPA provider, does not detect the modifications as the setXXX() methods are not invoked. Is there some way that I can ask XStream to use a different converter for this operation so the setXXX() methods will be invoked when assigning the values?

Thanks....

Chris Mathrusse
christopher.mathrusse@...

Re: How to use fromXML() without using the ReflectionConverter

by Sean Sullivan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Have you tried the JavaBeanConverter?

http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/converters/javabean/JavaBeanConverter.html


On Wed, Oct 14, 2009 at 11:38 AM, <Christopher.Mathrusse@...> wrote:

I'm attempting to use the fromXML(String, Object) method to update my target object, which happens to be a JPA entity. The issue that I'm having is that XStream uses the ReflectionConverter to assign the new values directly to the fields. This works just fine but EclipseLink, my JPA provider, does not detect the modifications as the setXXX() methods are not invoked. Is there some way that I can ask XStream to use a different converter for this operation so the setXXX() methods will be invoked when assigning the values?

Thanks....

Chris Mathrusse
christopher.mathrusse@...


Re: How to use fromXML() without using the ReflectionConverter

by cmathrusse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Do I need to use the converter directly or is there a way that I can configure XStream to use this Converter when the fromXML() method is invoked?

Thanks....

Chris Mathrusse
christopher.mathrusse@...



Re: [xstream-user] How to use fromXML() without using the         ReflectionConverter

Sean Sullivan to: user
10/14/2009 12:24 PM

Please respond to user








Have you tried the JavaBeanConverter?

http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/converters/javabean/JavaBeanConverter.html


On Wed, Oct 14, 2009 at 11:38 AM, <Christopher.Mathrusse@...> wrote:

I'm attempting to use the fromXML(String, Object) method to update my target object, which happens to be a JPA entity. The issue that I'm having is that XStream uses the ReflectionConverter to assign the new values directly to the fields. This works just fine but EclipseLink, my JPA provider, does not detect the modifications as the setXXX() methods are not invoked. Is there some way that I can ask XStream to use a different converter for this operation so the setXXX() methods will be invoked when assigning the values?


Thanks....


Chris Mathrusse

christopher.mathrusse@...


Re: How to use fromXML() without using the ReflectionConverter

by Jörg Schaible-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Chris,

Christopher.Mathrusse@... wrote at
Mittwoch, 14. Oktober 2009 21:28:

> Do I need to use the converter directly or is there a way that I can
> configure XStream to use this Converter when the fromXML() method is
> invoked?

You have to register it for your types:

xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()) {
    boolean canConvert(Class type) {
        return type == YourClassType.class || (<type is JPA manged bean>);
    }
})

- Jörg


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

    http://xircles.codehaus.org/manage_email