Questions tagged [dozer]

Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.

From the Dozer website:

Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types.

Dozer supports simple property mapping, complex type mapping, bi-directional mapping, implicit-explicit mapping, as well as recursive mapping. This includes mapping collection attributes that also need mapping at the element level.

Dozer not only supports mapping between attribute names, but also automatically converting between types. Most conversion scenarios are supported out of the box, but Dozer also allows you to specify custom conversions via XML.

530 questions
26
votes
4 answers

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

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"); …
Thai Tran
  • 9,815
  • 7
  • 43
  • 64
26
votes
8 answers

How to map collections in Dozer

I'd like to do something like: ArrayList objects = new ArrayList(); ... DozerBeanMapper MAPPER = new DozerBeanMapper(); ... ArrayList newObjects = MAPPER.map(objects, ...); Assuming:
Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192
23
votes
5 answers

How to get the parent base class object super.getClass()

I have a little problem with Java (being a C++ programmer). I have 2 related classes: public class Patient() { ... } public class PatientPersistent extends Patient { ... public void foo() { System.out.println(super.getClass().toString()); …
code-gijoe
  • 6,949
  • 14
  • 67
  • 103
22
votes
3 answers

Alternative to dozer for bean mapping?

I am trying to figure out an easy way to map DTOs to entities without the boiler-plate code. While I was thinking of using dozer it appears to require a lot of xml configuration. Has anybody seen a dozer alternative that uses a DSL to configure…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
19
votes
6 answers

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

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…
Amit Kumar
  • 285
  • 1
  • 5
  • 13
18
votes
6 answers

Prevent Dozer from triggering Hibernate lazy loading

I am using Spring transactions so the transaction is still active when POJO to DTO conversion occurs. I would like to prevent Dozer from triggering lazy loading, so that hidden sql queries never occur : all fetching has to be done explicitly via HQL…
Tristan
  • 8,733
  • 7
  • 48
  • 96
16
votes
2 answers

Dozer String to enum mapping

I have such enum: public enum PartnershipIndicator { VENDOR("VENDOR"), COPARTNER("COPARTNER"), BUYER("BUYER"); String code; private PartnershipIndicator(String code) { this.code = code; } public String getCode() { …
madhead
  • 31,729
  • 16
  • 153
  • 201
15
votes
4 answers

Copying one class's fields into another class's identical fields

I have this question. But it will be difficult for me to explain as I don't know exact terms to use. Hope someone will understand. I'll try to discribe to the best i can. I feel like this is much related to parsing Say there are two classes. And in…
Anubis
  • 6,995
  • 14
  • 56
  • 87
13
votes
1 answer

Dozer: How to limit the depth of mappings?

I'm currently using Dozer for mapping Entity objects to Dto objects in my project. My question is how to limit the levels or the depth of internal mappings? For example I have a AccountProfile entity which has a List entity as…
STaefi
  • 4,297
  • 1
  • 25
  • 43
13
votes
2 answers

Mapping Lists of objects with Dozer

I created a dozer mapping for ClassA to ClassB. Now I want to map a List to a List. Is it possible to just mapper.map(variableListClassA, variableListClassB) or do I have to go over a loop, e.g. for (ClassA classA :…
user1323246
  • 433
  • 2
  • 6
  • 23
13
votes
5 answers

Dozer mapping JodaTime property not working as expected

I am using Dozer to map between a Document class to DocumentManagementBean class, both of my own making. Both have a property, with getters and setters, of Joda DateTime type, called dateAdded. When Document object d has property dateAdded=x,…
Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
12
votes
3 answers

How to use Dozer with Spring Boot?

I am working on a Spring Boot project. I just have annotation configuration. I want to include dozer to transform Entities to DTO and DTO to Entities. I see in the dozer website, they explain i have to add the following configuration in spring xml…
Pracede
  • 4,226
  • 16
  • 65
  • 110
11
votes
4 answers

dozer Boolean property mapping

It appears that Dozer will not map a Boolean property if the accessor of that property is defined as isProperty() rather than getProperty(). The following groovy script illustrates the problem: import org.dozer.* class ProductCommand { Boolean…
Dónal
  • 185,044
  • 174
  • 569
  • 824
11
votes
3 answers

validate related data when mapping view model to database model in Spring MVC

I'm working on a java spring mvc application and have an important question about mapping view model objects to database model objects. Our application uses dozer mapper for that purpose. Suppose I have a Person model and BaseInformation model. The…
hamed
  • 7,939
  • 15
  • 60
  • 114
11
votes
1 answer

Is it possible to configure Dozer such that by default fields are rather accessed directly that through setter-/getter method

I have to map a complex structure of Java classes which don't expose their fields through set-/get-methods in general (this is given and can't be changed). So mapping can only be performed on a direct field access. Dozer allows individual fields to…
Martin Ahrer
  • 937
  • 3
  • 15
  • 28
1
2 3
35 36