-->
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: Why is Hibernate setting all decimal points to zero in a Big
PostPosted: Tue Sep 02, 2014 5:49 pm 
Newbie

Joined: Tue Sep 02, 2014 5:45 pm
Posts: 4
Hello,

I am using Hibernate as my JPA provider and I have a "PRICE" column in a Sybase SQLAnywhere 16 database that is defied as decimal(19,4). The associated data is declared as:
Code:
@Basic(optional = false)
@NotNull
@Column(name = "PRICE", precision = 19, scale = 4)
private BigDecimal bdPrice;


I then load the data value with:
Code:
...
final BigDecimal bdTest = new BigDecimal("14276.5257");
bdTest.setScale(4,BigDecimal.ROUND_HALF_EVEN);
table.setBdPrice(bdTest);


and then I use em.persist() to get the data written to the database. A new row is written to the database and, using a Sybase database "editor" app, I can see that String columns are correct but the Price column shows:
14276.0000

I have tried defining the database column as double and money and with double I get 14276 and with money I get 14276.0000.

Also, if I manually (using the Sybase database "editor" app) load PRICE with, say, 11257.6914 I can fetch the row using Hibernate and getBdPrice() returns the exact value of 11257.6914 so the problem only happens on a write.

Can someone tell me what is going wrong here? How do I get the decimal digits into the database?

Thank you.


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.