Search code examples
javaspring-bootjpauuiddozer

Dozer copy UUID to UUID


I have a problem with the UUID field when trying to copy a class to another. example(spring boot,jpa ecc): I have 2 classes (equals) one is an entity and one is a model. When I'm copying for example from the entity to the model, dozer can't copy the right value of uuid but create a new one.

public class Entity{

    private UUID id;
    private string nome;
    //getter and setter and constructurs
}

public class Model{

    private UUID id;
    private string nome;
    //getter and setter and constructurs
}

If for example the entity is:

uuid id= "aaa-111-222" string name="example"

After doing

Model model=dozer.map(entity,Model.class)

The model id is uuid id="bss-555-555" ,name="example"

Why?? How can I convert it rigth? I see that this problem is caused because dozer can't find a constructor in UUID class (if I'm right).


Solution

  • It looks like you are using an old version of Dozer.

    This issue was addressed by Dozer time ago:

    https://github.com/DozerMapper/dozer/issues/83

    I have just tried version 6.1.0

    <dependency>
         <groupId>com.github.dozermapper</groupId>
         <artifactId>dozer-core</artifactId>
         <version>6.1.0</version>
    </dependency>
    

    and it works fine.

    Can you confirm your version?