Skip to content

Spring's naming strategy is no longer applied with globally_quoted_identifiers enabled #4091

@dgerhardt

Description

@dgerhardt

When jpa.properties.hibernate.globally_quoted_identifiers is enabled, Hibernate's default naming strategy (Java-like) is now applied instead of Spring's own (snake case). I haven't found anything regarding this new behavior in the release notes, so I guess this change is not intended.

Code example

@Entity
class DemoEntity {
    @Id var demoId: UUID? = null
}

Generated SQL for findByIdOrNull

Spring Boot 4.0.0:

select de1_0."demoId" from "DemoEntity" de1_0 where de1_0."demoId"=?

Spring Boot 3.5.8:

select de1_0."demo_id" from "demo_entity" de1_0 where de1_0."demo_id"=?

Stacktrace

[...]
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [ERROR: relation "DemoEntity" does not exist
  Position: 28] [select de1_0."demoId" from "DemoEntity" de1_0 where de1_0."demoId"=?]; SQL [select de1_0."demoId" from "DemoEntity" de1_0 where de1_0."demoId"=?]
[...]
Caused by: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [ERROR: relation "DemoEntity" does not exist
  Position: 28] [select de1_0."demoId" from "DemoEntity" de1_0 where de1_0."demoId"=?]
[...]
Caused by: org.postgresql.util.PSQLException: ERROR: relation "DemoEntity" does not exist
[...]

Reproduction

https://github.com/dgerhardt/spring-data-naming-case-bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions