I have a JSF application.
I've just included a layer of DTOs and I need to transfer Entity values to DTOs and vice versa.
Looking at Google, I found recommendations from Dozer in SOen.
I included the dependency and used it as Singleton as specified by the documentation.
Both entities and DTOs have the same field names, so you do not need explicit mapping (XML or annotations).
All in all, the application fixed extremely slowly after including Dozer dependency.
I even enabled the lib log to see what happened and everything is ok. I'm not going to post the log here because it's huge, but I've read it all over again and it's all right.
I'm using Hibernate with most relationships with FetchType.LAZY
. I include the configuration file dozer.properties
with the configuration below and the behavior remains the same.
dozer.beans.proxy-resolver-bean=org.dozer.util.HibernateProxyResolver
Here is the code for the utility class I created to copy the values:
import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
public final class CopyPropertiesUtil {
private static Mapper mapper = getInstance();
public static final Object copyProperties(final Object origin, final Class<?> destinationType) {
return origin == null ? null : mapper.map(origin, destinationType);
}
private static final Mapper getInstance() {
return mapper == null ? new DozerBeanMapper() : mapper;
}
}
Any help or suggestion is welcome.