openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: Known issues - Floats and doubles may lose precision when stored.
Date Thu, 07 Jan 2010 17:37:03 GMT
Well I haven't fully tested all possible cases, but my app works to 4
decimal places so I use the column definition shown below (6 places) and I
do not get rounding issues any more. It was a big problem for me when I
first started using OpenJPA a year or so ago because I am back calculating
tax on low value high qty items. 


-----Original Message-----
From: Daryl Stultz [] 
Sent: Friday, 8 January 2010 12:30 AM
Subject: Re: Known issues - Floats and doubles may lose precision when

On Thu, Jan 7, 2010 at 6:24 AM, C N Davies <> wrote:

> I'm no expert on this but I find OpenJPA 1.2.1 works just fine on
> ProgresSQL
> when I use specific notation
>        @Column(columnDefinition="DOUBLE UNSIGNED",precision=10,scale=6,
> nullable=false)
>        private double rate = 0.00;
> If I don't use the column definition it's a mess

The manual [1] states that columnDefinition, precision, and scale are used
for database creation (DDL generation). I'm wondering if you have the
database column correctly does that prevent precision loss or is there value
truncation of some kind before going to the database.


Daryl Stultz
6 Degrees Software and Consulting, Inc.

View raw message