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. 

Chris


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

On Thu, Jan 7, 2010 at 6:24 AM, C N Davies <[email protected]> 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.

[1]
http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/jpa_
overview_mapping_column.html


-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]

Reply via email to