I don't think Derby supports specifying the precision on type DOUBLE (maybe
other datbases do).

You should be able to specify the precision through the @Column annotation.
I believe @Column(columnDefinition="DECIMAL(5,2)") will work. I'm not sure
whether precision=x, scale=y with a type that maps to DECIMAL instead of

On 4/10/07, Jacek Laskowski < [EMAIL PROTECTED]> wrote:


I wonder how I could restrict what values are inserted into a table
using @Column(precision=5, scale=2). When does it matter?

I'm using OpenJPA 0.9.7-SNAPSHOT with Derby and with the following:

    @Column(precision = 5, scale = 2)
    public double getPensja() {
        return pensja;

OpenJPA executes the following CREATE

2969  derbyPU  TRACE  [main] openjpa.jdbc.SQL - <t 11533424, conn
18662247> executing stmnt 23119024 CREATE TABLE Osoba (numer BIGINT
NOT NULL, dzienImienin TIMESTAMP, dzienUrodzin
TIMESTAMP, imie VARCHAR(255), kraj VARCHAR(255), nazwisko
VARCHAR(255), wersja INTEGER, pensja DOUBLE, tytul VARCHAR(255),
PRIMARY KEY (numer))

How could I restrict the precision and scale of the pensja field? Is
the columnDefinition attribute of @Column the last resort? When is the
others used? What databases are supported?


Jacek Laskowski

-Michael Dick

Reply via email to