Files

27 lines
1.7 KiB
Plaintext

== 1. A typo in a field name: when does it fail? (not at compile time)
failed while building the mapper: MappingException: No read or write method found for field (emial) in class (class com.ankurm.beanmapping.model.UserDTO)
== 2. A field nobody maps: email -> emailAddress without the configuration line
no exception, no log line. emailAddress=null
== 3. A new column on the entity (phone): does Dozer notice?
no exception, no log line. UserEntityV2[id=1, username=ankurm, emailAddress=null, phone=null]
== 4. Records: as destination, then as source
record destination failed: MappingException: java.lang.NoSuchMethodException: com.ankurm.beanmapping.model.UserRecord.<init>() [root cause NoSuchMethodException: com.ankurm.beanmapping.model.UserRecord.<init>()]
record source: no exception, but look at the result: UserDTO[id=0, username=null, email=null, profile=null, tags=[]]
== 5. A converter registered globally, applied to a list, entity -> DTO
DTO to entity worked: [Tag[Java], Tag[Spring Boot], Tag[Dozer], Tag[MapStruct], Tag[JMH]]
entity to DTO, no exception: tags=[Tag[Java], Tag[Spring Boot], Tag[Dozer], Tag[MapStruct], Tag[JMH]]
convertFrom() was never used: the elements are TagEntity.toString() output
with a field-level converter: tags=[Java, Spring Boot, Dozer, MapStruct, JMH]
== 6. A lazy getter: does Dozer call it?
map() failed: MappingException: java.lang.reflect.InvocationTargetException [root cause IllegalStateException: could not initialize proxy - no Session (simulated lazy collection)]
getOrders() was called 1 time(s)
== 7. Same kind of entity, orders excluded in the mapping
map() succeeded: LazyUserView[id=6, name=lazy2, orders=null]
getOrders() was called 0 time(s)