atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl is not mapped by default #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an instance of a class with XMLGregorianCalendar type field
2. Try mapping it into the same / similar class.

What is the expected output? What do you see instead?
It should map the source to target instance without any issue.
Instead we see an exception as follows:
Exception in thread "main" ma.glasnost.orika.MappingException: While attempting 
the folling mapping:
sourceType = XMLGregorianCalendarImpl
destinationType = XMLGregorianCalendar
Error occurred: No concrete class mapping defined for source class 
com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
    at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:213)

What version of the product are you using? On what operating system?
1.2.1 / MS Windows XP

Please provide any additional information below.

Original issue reported on code.google.com by meetma...@gmail.com on 20 Sep 2012 at 10:25

GoogleCodeExporter commented 9 years ago
Please try the following (on the DefaultMapperFactoryBuilder):
new DefaultMapperFactory.Builder().useBuiltinConverters(true).build();

Original comment by matt.deb...@gmail.com on 20 Sep 2012 at 8:47

GoogleCodeExporter commented 9 years ago
Hi,
Thanks for the prompt suggestion. I tried the following. It wouldn't work 
though. At the moment I'm creating CustomConverter to address this issue.
public com.company.abc.Person translate(
            Person person) {
        MapperFacade mapper = new MyCustomMapper();
        return mapper.map(person,
                com.company.abc.Person.class);
    }

    public class MyCustomMapper extends ConfigurableMapper {

        @Override
        public void configure(MapperFactory factory) {
            // register class maps
            factory.registerClassMap(factory
                    .classMap(
                            Person.class,
                            com.company.abc.Person.class)
                    .byDefault().toClassMap());

            // register mappers         
            // register object factories            
            // register converters

        }

        @Override
        public void configureFactoryBuilder(DefaultMapperFactory.Builder builder) {
            // configure properties of the factory, if needed
            builder.usedBuiltinConverters(true);
        }
    }
Regards,
Srimathi

Original comment by meetma...@gmail.com on 24 Sep 2012 at 2:59

GoogleCodeExporter commented 9 years ago
Sorry, now that I look into the details properly, I see that you're trying to 
map XMLGregorianCalendar to itself.
There are basically 2 options for this: 
 (1) decide to treat XMLGregorianCalendar as an immutable type (we know it's not, technically) and use a PassThroughConverter
 (2) use your own custom converter as mentioned 

I can add a built-in converter for this to the existing ones...

Original comment by matt.deb...@gmail.com on 5 Oct 2012 at 4:26

GoogleCodeExporter commented 9 years ago
A fix for this has now been provided in the 1.3.1 trunk; a new type of 
converter CloneableConverter has been added (which is parallel to 
PassThroughConverter, but calls clone() on the types instead of passing them by 
reference.
XMLGregorianCalendar, java.util.Date, and java.util.Calendar are all added to a 
default instance of this Converter that is registered with BuiltinConverters by 
default.

If you have the ability to test with the latest trunk, could you confirm this 
resolves your issue?

Original comment by matt.deb...@gmail.com on 5 Oct 2012 at 6:42

GoogleCodeExporter commented 9 years ago
Fixed in 1.3.4 release.

Original comment by matt.deb...@gmail.com on 19 Oct 2012 at 10:49