11
votes

i am using hibernate. it has id column with 20 precisions as below but of NUMBER type.

NUMBER(38,20) - this is the size given to id column of the table(Oracle database).

This id is generated by our application. in entity if i use Float or Double it cannot accommodate 20 precisions. but java.math.BigDecimal can accommodate these many precisions. but the problem is can i use BigDecimal in hbm as below? will there be any problems? some times i may not send id with precisions. that time will hibernate generates any empty precision and inserts?

<id name="someId" column="SOME_ID" type="java.math.BigDecimal"/>

Please suggest!

1

1 Answers

10
votes

You can use type="big_decimal". Under no circumstances should you even attempt to use Float or Double for this.