-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Issue regarding the use of java.math.Bigdecimal with MSQLSER
PostPosted: Mon Mar 14, 2005 10:16 am 
Newbie

Joined: Mon Mar 14, 2005 10:06 am
Posts: 1
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.