I'm new to dozer and I have an issue I can't get a grip on.
I have the following:
Class A_DTO en B_DTO.
In class A_DTO one of the fields is of type B_DTO
I have two regular dozer mapper for mapping A_DTO <-> A and B_DTO to B
When I map from A_DTO to A, I see that alle the mapping works but object B_DTO in A_DTO hasn't been mapped (B in A = null). I thought this "internal" mapping would be taking care of.
I'm using a regular mapping class :
public abstract class Mapper<D, T=""> {
protected org.dozer.DozerBeanMapper mapper;
public Mapper() {
List<String> file = new ArrayList<String>();
file.add("dozerBeanMapping.xml");
mapper = new DozerBeanMapper();
// mapper.setMappingFiles(file);
}
public abstract D mapToDTO(T domainObject);
public abstract T mapToDomainObj(D dto);
public ArrayList<D> mapAllToDTO(List<T> domainObjects) {
ArrayList<D> dtoList = new ArrayList<D>();
for (T t : domainObjects) {
dtoList.add(mapToDTO(t));
}
return dtoList;
}
public ArrayList<T> mapAllToDomainObject(List<D> dtos) {
ArrayList<T> domainObjects = new ArrayList<T>();
for (D d : dtos) {
domainObjects.add(mapToDomainObj(d));
}
return domainObjects;
}
};
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm new to dozer and I have an issue I can't get a grip on.
I have the following:
Class A_DTO en B_DTO.
In class A_DTO one of the fields is of type B_DTO
I have two regular dozer mapper for mapping A_DTO <-> A and B_DTO to B
When I map from A_DTO to A, I see that alle the mapping works but object B_DTO in A_DTO hasn't been mapped (B in A = null). I thought this "internal" mapping would be taking care of.
I'm using a regular mapping class :
public abstract class Mapper<D, T=""> {
protected org.dozer.DozerBeanMapper mapper;
public Mapper() {
List<String> file = new ArrayList<String>();
file.add("dozerBeanMapping.xml");
mapper = new DozerBeanMapper();
// mapper.setMappingFiles(file);
}
public abstract D mapToDTO(T domainObject);
public abstract T mapToDomainObj(D dto);
public ArrayList<D> mapAllToDTO(List<T> domainObjects) {
ArrayList<D> dtoList = new ArrayList<D>();
for (T t : domainObjects) {
dtoList.add(mapToDTO(t));
}
return dtoList;
}
public ArrayList<T> mapAllToDomainObject(List<D> dtos) {
ArrayList<T> domainObjects = new ArrayList<T>();
for (D d : dtos) {
domainObjects.add(mapToDomainObj(d));
}
return domainObjects;
}
};