I have inserted value into DB float column using hibernate.The inserted value is 0.00000000000000001. When I did a select from , in SQL plus window, I see that value is inserted and displayed correctly. However when I retrieve the same value using hibernate load method, it displays exponential value. How to avoid this ?
Asked
Active
Viewed 133 times
0
-
Please share the code where you are trying to use the value. – Ketu Feb 01 '16 at 13:21
-
As SQL*Plus shows the correct value the data has obviously been inserted properly into the database, so what you're seeing is a formatting issue in whatever client, tool, or language you're using. Best of luck. – Bob Jarvis - Слава Україні Feb 01 '16 at 13:45
-
Contact contact1 = new Contact("babusailesh1117777", "hainatu1@gmail.com", "Vietnam1", "0904277091",new BigDecimal("0.00000000000000001")); session.persist(contact1); session.getTransaction().commit(); session.flush(); session.close(); session = sessionFactory.openSession(); Contact contact5 = (Contact) session.load(Contact.class, new Integer(2)); System.out.println(contact5.getAmount()); – user2354566 Feb 01 '16 at 14:04
-
The getamount method return exponential value – user2354566 Feb 01 '16 at 14:08
-
Possible duplicate of [How to print formatted BigDecimal values?](http://stackoverflow.com/questions/3395825/how-to-print-formatted-bigdecimal-values) – Dragan Bozanovic Feb 01 '16 at 14:13