Decimal columns on Microsoft SQL Server
SQL Server reads a DECIMAL or NUMERIC column without a precision as DECIMAL(18,0), so a value such as 2.5 was stored and read back as 3 (OPENJPA-3064).
SQLServerDictionary now writes the precision and scale of a decimal column into the generated DDL: an attribute mapped with @Column(precision = 10, scale = 2) gets a NUMERIC(10, 2) column.
A BigDecimal, Number, double or float attribute mapped to a decimal column without a precision gets the largest precision SQL Server allows, 38 digits.
The scale is the scale of the mapping if one is given, at most 38, otherwise 10, which leaves 28 digits before the decimal point: a BigDecimal without @Column(precision) gets a NUMERIC(38, 10) column and @Column(scale = 2) gets NUMERIC(38, 2).
Values are read back with the scale of the column, 2.5 as 2.5000000000 in the first case, so compare them with compareTo rather than equals.
An exact type was chosen over FLOAT so that decimal values are not rounded to binary fractions.
Since the precision is now part of the DDL, a @Column(precision) above 38 gives DDL that SQL Server rejects; before, such a column was created as DECIMAL(18,0).
Integral attributes such as BigInteger keep their column type, and a columnDefinition is used as given.
A NumericTypeName or DecimalTypeName set on the dictionary is used as before, for unsized columns too.
Tables created by earlier releases are not altered by the mapping tool or SynchronizeMappings: an existing DECIMAL(18,0) column is accepted as it is and keeps rounding to integers.
Migrate the affected columns, for example ALTER TABLE PRODUCT ALTER COLUMN PRICE DECIMAL(10, 2), and check the stored values, which were already rounded.