Hi all,
we use hibernate-tools in order to generate Hibernate mapping files and have implemented our own reverse engineering strategy. Now I have come across some peculiarities regarding the NUMBER type.
Side remark: The impact of the behaviour described below will become evident when implementing an alternate reverse engineering strategy that maps a BigInteger when the scale is zero and a BigDecimal otherwise.
The issues:
1) A number type can have a precision and a scale. When no precision is given, e.g. in NUMBER(*,2), then hibernate-tools will take the data length of the NUMBER field as the default column size. In my testcases the data length was always 22 bytes. I think a better choice for the default column size would be the maximum allowed precision, i.e. 38.
2) When no precision and scale are given for the NUMBER field, then Oracle will store the value as is, meaning with an arbitrary number of decimal places. Hibernate-tools will default to a precision of 22 and zero decimal digits (because null will become zero in the default case). I would suggest setting precision and scale to 38.
I have added two corresponding pull requests on Github and would really appreciate your comments.
With kind regards,
Thorsten Schäfer
|