问题
Is there a way to cast a String to a BigDecimal in a jooq-query without losing precision?
When i do endResER.VALUE.cast(BigDecimal.class) where VALUE is a field with a String-value in the database it returns a BigDecimal without any fraction digits.
I need to compare two amounts that are saved as Strings in the DB.
回答1:
You can cast your value to a SQLDataType like this:
endResER.VALUE.cast(SQLDataType.DECIMAL.precision(10, 5))
Beware though, that there is a known issue for jOOQ 3.1: #2708.
来源:https://stackoverflow.com/questions/18401667/jooq-casting-string-to-bigdecimal