Jooq casting String to BigDecimal

人走茶凉 提交于 2019-12-23 22:29:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!