Answer the question
In order to leave comments, you need to log in
Why does the given Naming Strategy in Spring Boot not work?
I use Spring Boot + Hibernate.
In application.properties
indicated to use PhysicalNamingStrategy
:
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
GiftCertificate
. But for some reason, when the request is executed, the name of this class is not converted to gift_certificate
, as expected by me, but to giftcertificate
, which can be seen from the logs:java.sql.SQLSyntaxErrorException: Table 'gift_certificates_system_db.giftcertificate' doesn't exist
Answer the question
In order to leave comments, you need to log in
ImplicitNamingStrategy
used when the database name, table name, column name is not explicitly specified in the entity definition. Those. when the @Table annotation is not used, or when the @Column annotation is present but the name property is not set.
PhysicalNamingStrategy
the strategy comes into play when the database name, table name, column name is explicitly set, for example @Column(name = "camelCase")
. That's when Hibernate will already work with the value of the name parameter.
Properties are set in application.properties:
spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
ImplicitNamingStrategy
, not a PhysicalNamingStrategy
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question