0
votes

I have a Domain class with a Float field named hfMonto, and when updating it in the controller using

hfObject.properties=params

Being params:

enter image description here

When looking at the table, the hfMonto value is rounded up:

enter image description here

And the version field keeps increasing every time. Setting the hibernate logging to trace shows no errors or warnings.

I'm running Grails 3.3.11 on top of Java 1.8.0_252-8u252-b09-1ubuntu1-b09

Any hints? Thanks

UPDATE: it only happens with numbers bigger than 1,000,000

2
Does it really round - what does it do if you use 1 e.g.? - cfrick
In that case it rounds to zero (and version is incremented too) - xain
What data type is this in the database? - cfrick
float, and the db is 10.4.12-MariaDB-1:10.4.12+maria~bionic - xain
Could you please create Minimal Reproducible example? stackoverflow.com/help/minimal-reproducible-example - erichelgeson

2 Answers

1
votes

I finally made it work by changing the database field to double and the Domain attribute to BigDecimal.

0
votes

My suggestion is to check the database field; sometimes the database field (in the actual database) does not match the hibernate field

Make sure that what you are returning from your frontend is what you are expecting; sometimes the frontend returns a 'string' which chops the floating point.