ドメイン クラスの BigDecimal フィールドにリクエスト パラメータをバインドする際に、いくつかの問題に直面しています。
期間フィールドに 25.75 を入力すると、データが正しくシリアル化され、期間が正しい精度で要求でコントローラーに渡されます。
コントローラーのアクション:
def save() {
// params.duration is 25.75 (debugged and printed to the console)
def entry = new Entry(params)
// entry.duration is now 25
// the precision is lost..
// 125.25 converts to 125
// 1.75 converts to 1
...
}
ドメイン クラス:
class Entry {
BigDecimal duration
static constraints = {
duration(min: 0.01G, max: 168.00G, scale: 2)
}
}
MySQL データベースのカラム タイプは DECIMAL(5,2) です。
明らかな何かが欠けていますか?
編集: Grails バージョン 2.2.0 を使用します。