empire-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivan nemeth <ivan.nem...@forumdigital.net>
Subject BigDecimal scale question
Date Tue, 29 Jul 2014 15:27:12 GMT

I try to define a DECIMAL column with precision 38 and scale 10.

WEIGHT = addColumn("weight", DataType.DECIMAL, 38.10, true);

doesn't work, but the following is ok:

WEIGHT = addColumn("weight", DataType.DECIMAL, 38.99, true);

and it generates a column with type decimal(38, 10)  (MySql).
In queries it works fine, the extracted BigDecimal value has the expected
scale of 10. The problem is when I want to update/insert a row, where the
BigDecimal value has a scale of 10, the following exception is thrown:

 org.apache.empire.db.exceptions.FieldValueOutOfRangeException: The value
supplied for field ![testdb.asset_composition.weight] is out of range.
at org.apache.empire.db.DBTableColumn.validateNumber(DBTableColumn.java:462)
 at org.apache.empire.db.DBTableColumn.validate(DBTableColumn.java:367)
at org.apache.empire.db.DBRecord.validateValue(DBRecord.java:619)
 at org.apache.empire.db.DBRecord.setValue(DBRecord.java:572)
at org.apache.empire.db.DBRecord.setValue(DBRecord.java:590)

In my opinion the problem is that
the org.apache.empire.db.DBTableColumn.validateNumber method uses a
different algorithm to extract the scale and precision from the supplied


View raw message