openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <michael.d.d...@gmail.com>
Subject Re: @Column with precision and scale - how does it work?
Date Tue, 10 Apr 2007 20:01:06 GMT
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
DOUBLE.


On 4/10/07, Jacek Laskowski < jacek@laskowski.net.pl> wrote:
>
> Hi,
>
> 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
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>



-- 
-Michael Dick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message