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.