dozer

Dozer deep mapping not working

匆匆过客 提交于 2020-02-05 17:12:47
问题 I am trying to use dozer 4.1 to map between classes. I have a source class that looks like this: public class initRequest{ protected String id; protected String[] details } I have a destination class that looks like this: public class initResponse{ protected String id; protected DetailsObject detObj; } public class DetailsObject{ protected List<String> details; } So essentially i want the string in the details array to be populated into the List in the Details object. I have tried a mapping

Mapping JPA or Hibernate projection query to DTO (Data Transfer Object)

萝らか妹 提交于 2020-01-22 05:25:06
问题 In my DAO layer, I have a Find function like this public List<?> findCategoryWithSentenceNumber(int offset, int maxRec) { Criteria crit = getSession().createCriteria(Category.class, "cate"); crit.createAlias("cate.sentences", "sent"); crit.setProjection(Projections.projectionList(). add(Projections.property("title"), "title"). add(Projections.count("sent.id"), "numberOfSentence"). add(Projections.groupProperty("title")) ); crit.setFirstResult(offset); crit.setMaxResults(maxRec); return crit

Converting a nested collection using Dozer

二次信任 提交于 2020-01-14 12:56:10
问题 I have a class A which has a nested set of class B: public class A { private Set<B> children; } public class B { private int value; } I also have a class C which has a nested set of class D: public class C { private Set<D> children; } public class D { private int value; } Now given a List of A, how do I convert it to a List of C? Ideally I should not have to supply any mapping hints since I am using generics. For example: List<A> src = new ArrayList<A>(); // ----- Add some A's to src -----

Copy pojo fields to another pojo's setters

泄露秘密 提交于 2020-01-14 08:14:10
问题 Let's say I have class A with public fields x and y . And let's say I have another pojo class B but that uses setters and getters, so it has setX() and setY(). I'd like to use some automatic way to copy from instance of A to B and back. With default settings at least, Dozer's Mapper mapper = new DozerBeanMapper(); B b = mapper.map(a, B.class); does not copy the fields correctly. So is there a simple configuration change that allows me to accomplish the above with Dozer, or another library

Dozer: Hibernate PersistentMap is not mapped to java.util.HashMap

早过忘川 提交于 2020-01-05 00:55:27
问题 I have a Hibernate annotated entity with a field: @OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER) @MapKey(name = "attributeName") private Map<String, Component> components; Hibernate makes a PersistentMap out of this. Then I want Dozer to map this to an object with such a field: private Map<String, ComponentDto> components; After having LazyInitializationExceptions and some debugging, I found out, that it´s not a problem of a closed Hibernate session, but that Dozer tries not

Dozer: Hibernate PersistentMap is not mapped to java.util.HashMap

泄露秘密 提交于 2020-01-05 00:55:11
问题 I have a Hibernate annotated entity with a field: @OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER) @MapKey(name = "attributeName") private Map<String, Component> components; Hibernate makes a PersistentMap out of this. Then I want Dozer to map this to an object with such a field: private Map<String, ComponentDto> components; After having LazyInitializationExceptions and some debugging, I found out, that it´s not a problem of a closed Hibernate session, but that Dozer tries not

Dozer: Hibernate PersistentMap is not mapped to java.util.HashMap

拈花ヽ惹草 提交于 2020-01-05 00:55:09
问题 I have a Hibernate annotated entity with a field: @OneToMany(mappedBy="templateInstance", fetch = FetchType.EAGER) @MapKey(name = "attributeName") private Map<String, Component> components; Hibernate makes a PersistentMap out of this. Then I want Dozer to map this to an object with such a field: private Map<String, ComponentDto> components; After having LazyInitializationExceptions and some debugging, I found out, that it´s not a problem of a closed Hibernate session, but that Dozer tries not

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader

三世轮回 提交于 2020-01-02 00:39:28
问题 I am getting the following error , while running my following code: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.dozer.util.ResourceLoader.getResource(ResourceLoader.java:53) at org.dozer.util.DefaultClassLoader.loadResource(DefaultClassLoader.java:44) at org.dozer.config.GlobalSettings

Dozer and Spring integration

给你一囗甜甜゛ 提交于 2020-01-01 03:19:07
问题 EDIT : A new lib has been introduced which clarify the thing for new versions Since version 5.5.0 Spring integration comes within additional module dozer-spring. Hi there I'm relatively new to Dozer and Spring and a bit confused about how to put that in place. From the dozer website : http://dozer.sourceforge.net/documentation/usage.html Spring integration ... <bean id="mapper" class="org.dozer.DozerBeanMapper"> <property name="mappingFiles"> <list> <value>dozer-global-configuration.xml<

Dozer Singleton Startup Bean injetced as Null

ぐ巨炮叔叔 提交于 2019-12-24 13:26:25
问题 I have created an instatiator bean for Dozer (http://dozer.sourceforge.net/). But when I Inject this EJB it throws nullpointer exception. Here is my Singleton Startup Bean for intialising Dozer package com.unijunction.ordercloud.common.rest; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Singleton; import javax.ejb.Startup; import org.dozer.DozerBeanMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Startup @Singleton public class