1

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:

@Basic(optional = false)
@NotNull
@Column(name = "PRICE", precision = 19, scale = 4)
private BigDecimal bdPrice;

I then load the data value with:

...
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 ony 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.

Al Koch
  • 391
  • 1
  • 6
  • 19
  • Hey, do you use JConnect? If yes, it can be helpful discussion - http://sqlanywhere-forum.sap.com/questions/19622/jconnect-7-truncates-bigdecimal-value – sap1ens Sep 03 '14 at 04:32
  • Hi sap1ens. I've spent several days researching your link but no success. I am using SQLAnywhere 16, jConnect 7 and SQLAnywhere16Dialect as the Hibernate dialect. It looks like declaring the data a String vs. BigDecimal is an ugly hack to get around this. Any idea about a real fix? Any idea why hasn't Sybase/SAP fixed this? Thanks for your help. – Al Koch Sep 05 '14 at 22:43

0 Answers0