ccavanaugh / jgnash

jGnash Personal Finance
http://ccavanaugh.github.io/jgnash/
Other
139 stars 80 forks source link

Fix issue with negative scale for default currency. #95

Closed t-pa closed 3 years ago

t-pa commented 3 years ago

The scale of the default currency is -1, but this is not allowed for CurrencyNodes. This led to an exception when creating a new file on a system with a locale without a default currency:

[2021-02-20 22:04:52] [INFORMATION] {jgnash.engine.jpa.JpaConfigDAO lambda$getDefaultConfig$0} Generating new default config [2021-02-20 22:04:52] [WARNUNG] {jgnash.engine.Engine getDefaultCurrency} No default currency assigned [2021-02-20 22:04:52] [SCHWERWIEGEND] {jgnash.engine.Engine logSevere} Commodity XXX had a scale less than zero [2021-02-20 22:04:52] [INFORMATION] {jgnash.engine.Engine logInfo} Creating RootAccount [2021-02-20 22:04:52] [SCHWERWIEGEND] {jgnash.util.LogUtil logSevere} Error while committing the transaction javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:81) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104) at jgnash.engine.jpa.AbstractJpaDAO.lambda$persist$3(AbstractJpaDAO.java:204) at jgnash.engine.concurrent.PriorityThreadPoolExecutor$2.call(PriorityThreadPoolExecutor.java:71) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jgnash.engine.RootAccount.currencyNode -> jgnash.engine.CurrencyNode