0

I have upgraded spring boot h2 to 2.1.210 from 1.4.199. My tests are failing because of following error:

NULL not allowed for column "modified"

But in the create table DLL for h2, its been specified to set this to current timeStamp as follow:

modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

My h2 connection string

spring.datasource.url=jdbc:h2:mem:abcdb;MODE=MYSQL;DB_CLOSE_DELAY=-1;
user124
  • 423
  • 2
  • 7
  • 26
  • Maybe you're explicitly passing a `null` to that field during an `insert` or `update`. Are you using an `Entity` to represent objects from that table? – Federico klez Culloca Oct 07 '22 at 13:49
  • No.It seems like a known issue .Just found https://stackoverflow.com/questions/39094649/h2-database-null-not-allowed-for-column-id-when-inserting-record-using-jdbcte, seems that UPDATE dont work on h2 latest version. But i dont know how to fix it. It was suggested to use MODE='LEGACY', in the link i pasted, but i have MODE=SQL already,not sure how to combine both – user124 Oct 07 '22 at 13:51
  • It isn't possible to insert `NULL` into regular `NOT NULL` column for obvious reasons in new versions of real MySQL with default settings (it was possible in old versions, they silently replaced it with default value) and it also isn't possible and shouldn't be possible in H2. MySQL still allows it only for `AUTO_INCREMENT` columns and H2 also allows that for them in some compatibility modes, including MySQL compatibility mode, but it isn't your case. – Evgenij Ryazanov Oct 07 '22 at 15:28

0 Answers0