Menu

#346 map(Object, Object) replaces instances in target Object

Dozer v5.3.2
open
nobody
5
2011-09-06
2011-09-06
No

When mapping to an instance instead of a Class it happens that the existing instances are replaced by new ones.
The following test shows this behavior and will fail with an AssertionFailedError:

public void test() {
// create one instance of each DT and setup the relations
DtA a = new DtA();
DtB b = new DtB();
DtC c = new DtC();

b.setC(c);
a.getBs().add(b);

// map to Entities
EntA entA = mapper.map(a, EntA.class);
// map back from Entity to given Datatype instance
mapper.map(entA, a);

assertTrue("The DtC instance differs", c == a.getBs().get(0).getC());
}

The test-code and a patch based on tags/5.3.2_RELEASE is attached.

Discussion

  • Benjamin Diefenbach

    the test-code

     
  • Benjamin Diefenbach

    The patch based on Dozer 5.3.2

     

Log in to post a comment.

MongoDB Logo MongoDB