I am using SORM as ORM in Scalatra application. I use Create as the initMode so that the tables are created automatically. I have a BigDecimal field as part of a case class, as below:
case class Invoice(invoiceId: String, invoiceAmount: BigDecimal)
There are 2 questions for which I am looking for the answers (might be it is just one answer):
- How to set the precision of BigDecimal field?
- How to set the precision of database column for invoiceAmount?
Is unboxed tagged types the way to go?
Taggedtypes is the only way out to have default precision for BigDecimal in case class.SORMby default usesDECIMAL(65,30)as the column's datatype for Decimal types. Which means you cannot set the precision of the database column unless you create the tables yourself, or customizeStdCreateTable.scalato handle that appropriately.