0

I want to save an amount in the database using JPA.

@Column(precision=8, scale=2)  
private BigDecimal amount;

But after persisting, the decimal values are always 0. E.g., when I create the amount with

amount = BigDecimal.valueOf(30.20D);

and store it to the database with em.persist(..), the value in the database is 30,00. When I use a sql update command, I can set it to any value, no problem.

This seems very strange. I use EclipseLink and Sybase DB.

user1119859
  • 669
  • 2
  • 9
  • 20
  • How is the column defined? – Claus Radloff Nov 27 '19 at 13:51
  • It's defined using – user1119859 Nov 27 '19 at 13:56
  • It's hard to guess what the problem is without debugging. I would recommend enabling the debug logs for the EclipseLink and investigate what parameters exactly it passes to DB. [How to enable logging](https://stackoverflow.com/questions/2374395/is-it-possible-to-output-generated-sql-using-eclipselink-without-having-to-incre) – Petr Aleksandrov Nov 27 '19 at 20:43

0 Answers0