I am trying to save BigDecimal in a new Grails 2.0 application and it does not behave at all as I expect.
I create a new application called l2bigdecand add this domain class:
package l2bigdec
class PlayMe {
BigDecimal imStupidOrSomething
static constraints = {
}
}
Then I put this code in bootstrap:
import l2bigdec.*
class BootStrap {
def init = { servletContext ->
def thisThingIHate = new PlayMe(imStupidOrSomething:0.912345).save(failOnError:true)
println thisThingIHate.imStupidOrSomething
PlayMe.withSession{it.clear()}
def getItBack = PlayMe.find{it}
println getItBack.imStupidOrSomething
}
def destroy = {
}
}
What prints:
0.912345
0.91
Why doesn't he print 0.912345 both times? Don't I understand BigDecimal?
source
share