Hello!
I'm using JPA with TopLink library and PostgreSQL database server.
I have a class with a BigDecimal field price:
@Entity
public class Price implements Serializable
{
/**
* Цена за единицу услуги.
*/
private BigDecimal price = new BigDecimal(0);
//...
}
Later in main() function:
//...
Price p = new Price();
BigDecimal bd = new BigDecimal(3.14);
p.setPrice(bd);
em.persist(p);
//...
bd object has scale = 51 and precision = 52. But JPA maps my field price to a table column of type NUMERIC(38,0). So 3.14 value is stored in database as 3 without fraction part.
Does anybody know why? And how can I control this?
Thank you.
PS: Maybe there is some Annotation which should be applied to my field price?