I'm facing some problems binding request parameters to a BigDecimal field in a domain class.
When I type in 25.75 in the duration field, the data is serialized correctly and the duration is passed to the controller in the request with correct precision.
Controller action:
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
...
}
The domain class:
class Entry {
BigDecimal duration
static constraints = {
duration(min: 0.01G, max: 168.00G, scale: 2)
}
}
The column type in MySQL database is DECIMAL(5,2).
Am I missing something apparent?
EDIT: Using Grails version 2.2.0.
params.duration) and after the save (entryInstance.duration). Also correct on thelistandshowpages as well as a direct select from the DB (mysql). Have you tried agrails cleanjust to check? - Kelly