Spring Data JDBC Generating Bad HSQLDB Query with Boot 2.3.0

前端 未结 1 1990
清歌不尽
清歌不尽 2021-01-22 18:27

I have a Spring Boot project that uses Spring Data JDBC. The tests use HSQLDB. My repository tests started failing when I attempted an upgrade to Spring Boot 2.3.0.

Spri

相关标签:
1条回答
  • 2021-01-22 18:52

    Looks like I was too quick to ask... A migration guide was published the same day I asked this question! https://spring.io/blog/2020/05/20/migrating-to-spring-data-jdbc-2-0

    The migration guide explains what I was observing:

    Quoting of Identifiers

    Spring Data JDBC 1.x uses table and column names mostly without changing them. This causes problems when you use an SQL key word as a property or entity name or when you tried to use some special character in a column name.

    For this reason Spring Data JDBC 2.0 quotes all identifiers by default. This makes the names case-sensitive, at least for most databases. Since we also, by default, convert the names generated into the default letter casing used by the database, this should not cause any problems, assuming you used no quotes in the CREATE TABLE statements, as most people do.

    Removing the @Table annotation and schemaName from the Liquibase change log removed my unintended use of quoting and solved the issue. As a bonus, I didn't need to create a schema anymore so I could remove spring.datasource.platform=hsqldb and the schema-hsqldb.sql file. See the fixed branch for the working version.

    Thanks for the nudge Jens Schauder!

    0 讨论(0)
提交回复
热议问题