Hi all ,
it seems that some precision is lost while using java.math.bigdecimal with msqlserver( when writting data).
for instance:
I) I used a bigdecimal as property.
<property name="bd"
type="java.math.BigDecimal"
column="BD"
length="2"
not-null="false"/>
II) Table is created by Hibernate as follow:
14:18:26,408 DEBUG SchemaExport: create table FarCousin (
COUSIN_ID numeric(19,0) not null,
FARCOUSIN varchar(256) null,
BD numeric(19,2) null,
primary key (COUSIN_ID)
)
III) Value is inserted in that way (java code):
fils.setBd(new BigDecimal(1234567891123456.87));
IV) read again the value within the DB.
14:18:26,439 INFO SchemaExport: schema export complete
Hibernate: insert into PERE (VERSION, CREATED, APERE) values (?, ?, ?)
Hibernate: insert into Cousin (ACOUSIN, PERE_ID) values (?, ?)
Hibernate: insert into FarCousin (FARCOUSIN, BD, COUSIN_ID) values (?, ?, ?)
Hibernate: select farcousin0_.COUSIN_ID as ID0_, farcousin0_.FARCOUSIN as FARCOUSIN3_0_, farcousin0_.BD as BD3_0_, farcousin0__1_.ACOUSIN as ACOUSIN2_0_, farcousin0__2_.VERSION as VERSION0_0_, farcousin0__2_.CREATED as CREATED0_0_, farcousin0__2_.APERE as APERE0_0_ from FarCousin farcousin0_ inner join Cousin farcousin0__1_ on farcousin0_.COUSIN_ID=farcousin0__1_.PERE_ID inner join PERE farcousin0__2_ on farcousin0_.COUSIN_ID=farcousin0__2_.ID where farcousin0_.COUSIN_ID=?
NDC : Paul
created : 2005-03-14 14:18:26.57
Identifier : 1
Identifier : 1234567891123456.75
And within the DB following value was inserted :
1234567891123456.75
Who can help me ?
Thanks a lot,
Pmalle.
[/b]
|