0

I've these classes Foo and Foo2 which needs to be mapped together

Class Foo{

    private double averageBalance;
    // getters and setters
    }

Class Foo2{

    private Double averageCurrentBalance;
    // getters and setters

    }


Now I want to do mapping between Classes Foo and Foo2, something like this:

<mapping>
    <class-a>Foo</class-a>
    <class-b>Foo2</class-b>
    <field>
        <a>averageBalance</a>
        <b>averageCurrentBalance</b>
    </field>
</mapping>

But this isn't working, I'm looking for some custom converters, couldn't find any. Can someone please help ?

  • can you make them both double. auto boxing can be used post conversion – dom farr Mar 10 '16 at 20:41
  • also, if you are modelling money or currency double is not your friend. see http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency – dom farr Mar 10 '16 at 20:43
  • Not sure which version of Dozer you are using, but Dozer is able to map between primitive and object like Double/double. How did you implement the setters/getters? – Grzegorz Oledzki Mar 10 '16 at 20:46
  • @domfarr: No, I don't want to do it that way, I use this pojo else where, don't want to go with this approch. I just took an example for currentBalance just came on top of my head., this isn't for any currency/money modelling. – RIP SunMicrosystem Mar 10 '16 at 20:50
  • @GrzegorzOledzki: I'm using dozer 5.4.0. – RIP SunMicrosystem Mar 10 '16 at 20:52
  • From the Dozer FAQ. Will Dozer automatically perform data type conversions? Yes. Most scenarios are supported out of the box. These include primitives, Java Wrapper Objects, Number subclasses, Dates, Calendar, Collections, Arrays, Maps, and Complex types – dom farr Mar 10 '16 at 21:01
  • Exactly. http://dozer.sourceforge.net/documentation/simpleproperty.html specifies that clearly. That's why I suspect the actual problem is not with primitive vs. wrapper class. Without a full working example is hard to help with the problem. – Grzegorz Oledzki Mar 10 '16 at 21:10
  • FYI, I just incremented the dozer version to 5.1.1 and its working now. :) – RIP SunMicrosystem Mar 10 '16 at 21:27

0 Answers0