Home > Software design >  In JPA which @Column attributes must i have to map a NUMBER(6,3) field in an Oracle Table?
In JPA which @Column attributes must i have to map a NUMBER(6,3) field in an Oracle Table?

Time:06-07

I want to map an Oracle Table to a Java entity i create. In the Oracle table, i have :

  • a field called A of type NUMBER(6,3)
  • a field called B of type NUMBER(6, 0)

For the attribute in the Java entity corresponding to the field called A, must i have a BigDecimal (or a Float is sufficient) ? must i have with @Column (precision = 6, scale = 2) ?

I find maybe the BigDecimal a little heavy but if it is necessary, i will use it. I will in the future maybe use this entity to create table for my unitary tests with H2 (DDL). Maybe but for now, no DDL.

For the attribute in the Java entity corresponding to the field called B, is an attribute of type Integer (or int) sufficient ?

Thank you in advance for your answer. Thomas

CodePudding user response:

  1. BigDecimal since it's better to use BigDecimal than Float/Double for arithmetic operations.
  2. Integer will be fine.
  • Related