Closed magmel48 closed 8 years ago
Hi Max,
the only way that you have to solve this problem is by using Conversion method:
@JMapConversion(from={"category"}, to={"categoryId"})
public Long conversion(Long categoryId, Category category){
return category == null ? null: category.getId();
}
and change @JMap("${category.id}")
to @JMap("${category}")
This method is added to the configuration. so when you have solved the problems with the database you just delete it and restore the mapping.
there isn't a quicker solution at the moment
Hello, first of all, thank you for great library! I have one question according to nested mapping feature.
In example, I have
Application
class:class Application { Category category; ... }
AndCategory
class:class Category { Long id; ... }
I want to map
Application
toApplicationDto
class:class ApplicationDto { Long categoryId; ... }
For
categoryId
field I specified annotation@JMap("${category.id}")
and everything works great, but I got one problem. My database in some places is inconsistent and I can't fix it in near future. Because of that sometimes I can getnull
incategory
field and this annotation at the moment of mapping throws exception. ButLong
type can storenull
and my question is - is it possible to avoid exception and providenull
forcategoryId
ifcategory
field is alsonull
?