Using spring-boot-jpa in spring boot 3, an entity with field named columnWith1Number got auto-named column_with1number in the database.
After upgrading to spring boot 4.0.0-RC2, I found out that the auto-naming behaves differently, generating the database column named column_with1_number.
Example application with a test that tests for column naming:
https://github.com/bramvonk/bugreport-column-naming-spring-boot-4-issue
The spring boot 3 application builds 'correctly' with auto-created table:
Hibernate: create table example_entity (id integer not null, column_with1number varchar(255), primary key (id))
but after upgrading to spring boot 4 via this commit it fails due to the table being generated as:
Hibernate: create table example_entity (id integer not null, column_with1_number varchar(255), primary key (id))
I couldn't find anything about this in either Spring Boot 4 Migration Guide or the Hibernate 7.0 Migration Guide.
Comment From: snicoll
Thanks for trying the RC and the sample.
The change in column mapping is outside Spring Boot's control so this'll have to be reported against Hibernate. In Spring Boot 3.5 we used org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy but this was deprecated in favor of org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl and we followed suit and migrated to that. Both these classes are part of Hibernate.
Comment From: bramvonk
Thanks, found it, it's a breaking change introduced in https://hibernate.atlassian.net/browse/HHH-17310 . The maintainer said:
Note that this is in principle a (slightly) breaking change, but that’s something we can do in a major version like 7.0. If programs are depending on the old behavior, they can use their own custom naming strategy, or add @Column annotations to recover the old behavior.
(emphasis mine)
(Note that the behaviour change was introduced in Hibernate 7.0.0, even before CamelCaseToUnderscoresNamingStrategy was deprecated in 7.2.0.)