Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

  1. BigDecimal since it’s better to use BigDecimal than Float/Double for arithmetic operations.
  2. Integer will be fine.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading