Reputation: 62772
For my JPA entities I always annotate everything with @Table
and @Column
I don't want Hibernate to guess what the name of a table or column should be. I want Hibernate to use what is in my code.
I had an entity with the following field mapping
@Column(name = "isPrimary")
private Boolean isPrimary;
With Hibernate 4.x generated sql queries would list the column name as isprimary
however when I upgraded my app to use SpringBoot 1.4 from a traditional .war without SpringBoot. Hibernate 5 started using is_primary
as the column names in the queries that it generated which caused an exception because the database column is called isprimary
not is_primary
I changed my @Column(name = "isPrimary")
to @Column(name = "isprimary")
and Hibernate 5 went back to generating the column name correctly.
My understanding of JPA is that if you set @Column
then the JPA provider should respect that and not mess with the name in the annotation.
Upvotes: 0
Views: 1124
Reputation: 7622
Starting from Spring Boot 1.4, because of the switch to Hibernate 5, the naming strategy has been updated to SpringPhysicalNamingStrategy which should be very close to 1.3 defaults.
SpringNamingStrategy is no longer used as Hibernate 5.1 has removed support for the old NamingStrategy interface. A new SpringPhysicalNamingStrategy is now auto-configured which is used in combination with Hibernate’s default ImplicitNamingStrategy. This should be very close to (if not identical) to Spring Boot 1.3 defaults, however, you should check your Database schema is correct when upgrading.
Upvotes: 1