Hibernate @column Annotation Not Work
I hava SqlServer 2008 db server, And I use spring boot + jpa(hibernate) to access database. I have already add @Column annotation to entity properties access method, such as: @Bas
Solution 1:
By add this to config, My question was solved:
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Solution 2:
Check admin_pick_date string field name and its datatype(Upper lower case) by corresponding value.
Good Luck
Solution 3:
MSSQL Server can be case sensitive based on the settings
Edit: That was my mistake. have you changed anything from before ?
Have you set up following in your application.properties file ?
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
Solution 4:
Yes, the accepted answer is correct.
In case that you want to do more customization, you can extend SpringPhysicalNamingStrategy
and override the methods in it. And, choose that as impl of naming strategy in config.
In the code:
package app.config;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
publicclassMyNamingStrategyextendsSpringPhysicalNamingStrategy {
@OverridepublicbooleanisCaseInsensitive(JdbcEnvironment jdbcEnvironment) {
returnfalse; // MSSQL is case-sensitive
}
@Overridepublic Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return name; // we don't need adding underscore to the column name, we just use the name in "@Column(name="xxx")"
}
}
In yml file:
spring:jpa:properties:hibernate.physical_naming_strategy:app.config.MyNamingStrategy
Post a Comment for "Hibernate @column Annotation Not Work"