You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for an application we are using hibernate as ORM MApper and jadira for the conversion into java types.
We are converting from a mysql column decimal(19,2) into Yoda Money.
Our billing application now needs to support YEN. To all the currencies so far there is one crucial difference:
YEN does not have decimal places. Still it makes sense to store all the amounts into the same columns.
When you look at the code of yoda money, you see that yoda money will throw an exception if a big decimal with decimal points is provided.
The jadira converter (PersistentMoneyAmountAndCurrency) looks like this:
Now mysql will store for instance the amount '0' as '0.00' in the database. When converting to bigdecimal this value now has a scale. I think it is fixable by changing the code in the method "fromConvertedColumns".
For now I will just duplicate this class and make these changes myself.
The text was updated successfully, but these errors were encountered:
This is, what works for me. I assume the method "setScale" from BigDecimal will throw an aritmethic exception, if the values and the currency will not match.
Of course if this is a proper solution for all uses cases and if this is ready for including into the library, I don't know. For my use case for now, it seems like it get a bit further.
Hey Folks,
for an application we are using hibernate as ORM MApper and jadira for the conversion into java types.
We are converting from a mysql column decimal(19,2) into Yoda Money.
Our billing application now needs to support YEN. To all the currencies so far there is one crucial difference:
YEN does not have decimal places. Still it makes sense to store all the amounts into the same columns.
When you look at the code of yoda money, you see that yoda money will throw an exception if a big decimal with decimal points is provided.
The jadira converter (PersistentMoneyAmountAndCurrency) looks like this:
Now mysql will store for instance the amount '0' as '0.00' in the database. When converting to bigdecimal this value now has a scale. I think it is fixable by changing the code in the method "fromConvertedColumns".
For now I will just duplicate this class and make these changes myself.
The text was updated successfully, but these errors were encountered: