atos1990 / orika

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

Calendar as destination throwing exception #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. if the destination object is Calendar(java.util.Calendar)
example:

Source:
class Product {

 private Date tempCal;

}

Destination:

class ProductDTO {

 private Calendar tempCal;

}

What is the expected output? What do you see instead?
 It should map without any error, Instead it throws an exception

"No concrete class mapping defined for source class"

What version of the product are you using? On what operating system?
1.1.1 windows 7

Please provide any additional information below.

1) It should not throw any exception for Calendar, XMLGregorianCalendar 

Original issue reported on code.google.com by raok...@gmail.com on 8 May 2012 at 3:33

GoogleCodeExporter commented 9 years ago
(changed to an Enhancement request)
The default conversion from Date to Calendar and back again is not built-in; 
but as shown from the attached test case, it can easily be implemented by 
registering a BidirectionalConverter<Date, Calendar> on the mapper factory.

This does bring up a good point though -- there are some (maybe many) default 
conversions that you might just expect to take place (like this example); we 
can look at the possibility of adding default converters for these cases, 
depending on how it affects performance and also the ability to override...

Original comment by matt.deb...@gmail.com on 9 May 2012 at 2:21

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
As a part of the 1.2.0 branch, you can now automatically register an additional 
set of builtin converters (which includes the ability to handle this case), by 
applying a setting to the DefaultMapperFactory.Builder.
Like so:

    MapperFactory factory = new DefaultMapperFactory.Builder()
       .usedBuiltinConverters(true)
       .build();

It can also be done by explicitly registering the builtin 
DateAndTimeConverters.DateToCalendarConverter which can handle this type, like 
so:

    MapperFactory factory = new DefaultMapperFactory.Builder().build();
    factory.getConverterFactory().registerConverter(new DateAndTimeConverters.DateToCalendarConverter());

Original comment by matt.deb...@gmail.com on 9 Jul 2012 at 5:36