modelmapper / modelmapper

Intelligent object mapping
http://modelmapper.org
Apache License 2.0
2.29k stars 349 forks source link

ModelMapper struggles with Java types BigInteger & BigDecimal #285

Open rhanton opened 6 years ago

rhanton commented 6 years ago

It looks like there was a fix for this in https://github.com/modelmapper/modelmapper/issues/46, but that code is not present in master anymore for some reason. Can someone work on merging that fix back in?

chhsiao90 commented 6 years ago

I will take a look why this commit disappeared.

chhsiao90 commented 6 years ago

It looks like #79 removes the commit by #46. But I think #79 won't break anything. Is there any problem you had met? Can you post your reproducible code and exception stacktrace? Thanks

quangthe commented 6 years ago

I have the problem with BigDecimal as well. Source object has to fields cr = 12.45 and dr = 0 then after converting source object to dto, the dto has cr = 1 and dr = 0.

chhsiao90 commented 6 years ago

The unit test https://github.com/modelmapper/modelmapper/blob/master/core/src/test/java/org/modelmapper/bugs/GH46.java with our latest version of modelmapper, can you provide reproducible code? Thanks.

quangthe commented 6 years ago

@chhsiao90 In my code has some methods like boolean isCr() and boolean isDr(), that's why it has strange behavior. After rename these methods, the converter works well again.

chhsiao90 commented 6 years ago

Okay, I will check why Cr / Dr matter. May I know what's your modelmapper's version? Can you try upgrade to our latest release version? thanks.

chhsiao90 commented 6 years ago

hi @quangthe , Can you provide the source code for your source/destination classes? Thanks.

Kilrath commented 6 years ago

Regarding the unit Test above it only works due to a configured map defining source.member to destination.member. But this is what I want to avoid (for a long list of members) while using ModelMapper (2.3.0) otherwise I can map my code by hand which is easier!

saranshbansal commented 1 year ago

It's 2023 and I just faced this issue. The modelmapper is not mapping BigInteger and BigDecimal fields across entities. There is no exception or warning thrown beforehand.

version: 3.1.1