I'm trying to persist payment amount field as Big Decimal via Spring Data JPA (Hibernate). I have define column like this:
@Column(precision = 19, scale = 3)
but the problem I'm facing is that the the UP strategy is being used when rounding the number while persisting. For example, if i try to persist 0.12345 it will save 0.124.
I need the DOWN rounding strategy in this situation and i don't know how to set this. I can probably set the scale and rounding strategy for my big decimal in constructor/setters but that doesn't seem like good option to me. Is there some annotation or argument which i need to pass to my jpa so it uses the down strategy while rounding?
You can look here BigDecimal with JPA and flexible scale for some solution approach. I don't think it can be controlled with some property. I would say it's also not something that belongs on the domain layer, as it's a "business logic" to define how the prices are rounded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With