Home > Software design >  Getting SQL error after H2 upgrade from 1.x to 2.x
Getting SQL error after H2 upgrade from 1.x to 2.x

Time:01-19

Upgraded H2 from 1.4.200 to 2.0.206 and now in my integration tests I'm getting a 42001 Syntax error in SQL statement (JdbcSQLSyntaxErrorException) around this select: attributes0_.value[*] as value3_8_1_

I'm using hibernate entities. Also, using H2 only in a test environment.

I tried:

  • setting the H2Dialect in the test yaml file
  • logging the SQL statements to see if there's anything suspicious, with no luck

CodePudding user response:

The problem was I had an entity (hibernate) field name equal to a reserved word: value; that's why the stacktrace pointed it out with an asterix ([*]). A full list of keywords/reserved words can be found here.

This answer solved my issue, and I'm reposting here for the sake of people searching "h2 upgrade sql error"

Since it's a test environment, I made the quick fix of setting globally_quoted_identifiers: true in my test YAML file.

For production environments, make sure you either:

or a combination of these.

  •  Tags:  
  • Related