Menu

#196 Converting JAXBElement objects to Plain Old Java Types

open
nobody
5
2014-09-02
2009-12-22
Anonymous
No

Currently, Dozer does not support conversion from JAXBElement<Type> to java.*.type. It does not seem to recognize that these are different classes, and actually assigns the JAXBElement-wrapped value to the plain old java type object at runtime. This causes problems at runtime (generally, the converter also appears to be having trouble with parametrized types).

It would be great if parametrized (as they all have to be) JAXBElement objects could be automatically converted to their unwrapped value types. In other words, when given:
CLASS SOURCE:
JAXBElement<String> testString = new JAXBElement(new QName(), "JAXB Element String Value", String.class);
CLASS DESTINATION:
String testString = "";

In this case, calling mapper.map(source, Destination.class) should automatically call getValue() on the Source class's JAXBElement attribute, and set the Destination.testString value to that string.

Discussion

  • dmitry (lv)

    dmitry (lv) - 2010-01-03

    Right now I see a solution as simple as custom converter enabled globally in configuration block. We could provide that in the Dozer distribution for developers to enable.

     
  • Anonymous

    Anonymous - 2011-05-24

    When are you planning to add this feature (or offer theses custom converters)?

    Currently Dozer is nearly unusable for devs who are forced to work with jaxb...

     

    Last edit: Anonymous 2015-01-08
  • Kristof

    Kristof - 2012-10-16

    Still no movement here?

     

Log in to post a comment.