user1016403
user1016403

Reputation: 12621

Can i use BigDecimal as an id type in hibernate hbm?

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!

Upvotes: 11

Views: 5175

Answers (1)

J. Stoever
J. Stoever

Reputation: 866

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

Upvotes: 11

Related Questions