Open GoogleCodeExporter opened 8 years ago
Can you please attach a simple test case for the issue, so I can look at this
quickly.
Original comment by elaat...@gmail.com
on 5 Sep 2014 at 9:48
I've attached a test class but this test doesn't throw exceptions
mapping still here:
Field(createdDate(LocalDateTime), createdDate(Date)) : mapping object to object
but I don't see mapping generation.
My program have similar behavior and orika tries create LocalDateTime -> Date
mapping
05.09.14 13:44:39 [main] [] DEBUG m.g.orika.impl.DefaultMapperFactory - No
mapper registered for (Dto, Entity): attempting to generate
05.09.14 13:44:39 [main] [] DEBUG m.g.orika.metadata.ClassMapBuilder - ClassMap
created:
ClassMapBuilder.map(Dto, Entity)
.field( id(Long), id(Long) )
.field( name(String), name(String) )
.field( createdDate(LocalDateTime), createdDate(Date) )
.field( visible(Boolean), visible(Boolean) )
05.09.14 13:44:39 [main] [] DEBUG m.g.o.impl.generator.MapperGenerator -
Generating new mapper for (Dto, Entity)
Orika_Entity_Dto_Mapper1409924679235244000$15.mapAToB(Dto, Entity) {
Field(id(Long), id(Long)) : excluding because Entity.id(Long) is not assignable and cannot be mapped in-place
Field(name(String), name(String)) : copying String by reference
Field(createdDate(LocalDateTime), createdDate(Date)) : mapping object to object
Field(visible(Boolean), visible(Boolean)) : copying Boolean by reference
}
Orika_Entity_Dto_Mapper1409924679235244000$15.mapBToA(Entity, Dto) {
Field(id(Long), id(Long)) : copying Long by reference
Field(name(String), name(String)) : copying String by reference
Field(createdDate(Date), createdDate(LocalDateTime)) : converting using CustomConverter(DateToLocalDateTimeConverter)<Date, LocalDateTime>
Field(visible(Boolean), visible(Boolean)) : copying Boolean by reference
}
Types used: [LocalDateTime]
Converters used: [CustomConverter(DateToLocalDateTimeConverter)<Date, LocalDateTime>]
BoundMapperFacades used: [DefaultBoundMapperFacade<LocalDateTime, Date>]
05.09.14 13:44:39 [main] [] DEBUG m.g.orika.impl.MapperFacadeImpl -
MappingStrategy resolved and cached:
Inputs:[ sourceClass: app.core.Dto, sourceType: null, destinationType: class app.domain.Entity]
Resolved:[ strategy: MapExistingAndUseCustomMapperStrategy, sourceType: Dto, destinationType: Entity, mapper: GeneratedMapper<Dto, Entity> {usedConverters: [CustomConverter(DateToLocalDateTimeConverter)<Date, LocalDateTime>], usedMappers: [], usedMapperFacades: [DefaultBoundMapperFacade<LocalDateTime, Date>], usedTypes: [LocalDateTime] }, mapReverse?: false]
05.09.14 13:44:39 [main] [] DEBUG m.g.orika.impl.DefaultMapperFactory - No
mapper registered for (LocalDateTime, Date): attempting to generate
05.09.14 13:44:39 [main] [] DEBUG m.g.orika.metadata.ClassMapBuilder - ClassMap
created:
ClassMapBuilder.map(LocalDateTime, Date)
.field( month(Month), month(int) )
.field( year(int), year(int) )
05.09.14 13:44:39 [main] [] DEBUG m.g.o.i.g.s.PrimitiveAndObject -
PrimitiveAndObject condition occurred; context:
src: month(Month)
src.isArrayElement: false
src.isListElement: false
src.isMapKey: false
dest: month(int)
dest.isArrayElement: false
dest.isListElement: false
dest.isMapKey: false
05.09.14 13:44:39 [main] [] DEBUG m.g.o.impl.generator.MapperGenerator -
Generating new mapper for (LocalDateTime, Date)
Orika_Date_LocalDateTime_Mapper1409924679276935000$16.mapAToB(LocalDateTime, Date) {
<---- ERROR occurred here
ma.glasnost.orika.MappingException: While attempting the following mapping:
sourceType = java.time.LocalDateTime
destinationType = java.util.Date
Error occurred: ma.glasnost.orika.MappingException: While attempting the
following mapping:
sourceType = java.time.LocalDateTime
sourceProperty = month(Month)
destinationType = java.util.Date
destinationProperty = month(int)
Error occurred: ma.glasnost.orika.MappingException: Encountered mapping of
primitive to object (or vise-versa); sourceType=Month, destinationType=int
If you have any suggestions why orika may to do that, please let me know.
As I wrote additional custom mapper LocalDateTime > Date solves the problem, I
hope there is a better way :)
Original comment by Malyhi...@gmail.com
on 5 Sep 2014 at 2:04
Attachments:
Original issue reported on code.google.com by
Malyhi...@gmail.com
on 5 Sep 2014 at 8:49