mysql - Float value not being correctly persisted to database -


i have grails application in i'm parsing xml file , using parsed data create objects , persist them mysql database.

one of classes has float property:

class foo {     // ...     float myfloat      static constraints = {         myfloat(scale: 9) // trying specify 9 digits of precision, doesn't seem making difference     }      // ... } 

while parsing xml come attribute value of 6378137. want assign value myfloat:

class myservice{     // ...      def xml = new xmlparser().parsetext(myxmlfile.gettext())      def foo = new foo(         myfloat: xml.attribute("my_float")?.tofloat()     ).save()      // ... } 

at point in debugger can see value of myfloat 6378137.0. problem after transaction commits value stored in database 6378140.

why isn't myfloat being stored value assign it?

you'll have set precision , scale in gorm/hibernate..

look below link ...

http://appfuse.547863.n4.nabble.com/appfuse-user-hibernate-and-decimal-column-precision-td548279.html


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -