The Hibernate @Column annotation has the following default values:
- nullable = true
- insertable = true
- updateable = true
So Hibernate expects to be able to insert NULL values into the database by default. However, Corda's Kotlin entity classes do not always set nullable=false on their columns, even when the Kotlin type explicitly disallows null values. E.g. the VaultStates entity:
This entity seems to expect @Colum(nullable=false) by default as it never sets this flag when it needs to and only sets it when it doesn't.
Similarly, AbstractCashSelection.attemptSpend() is clearly (and incorrectly) assuming that it can never read NULL values from the database:
Our Hibernate entities need to impose the correct NULL/NOT NULL constraints on the database - whatever these correct values actually are.