遇到小写加下划线"_" 的命名
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
添加配置类
表名大写,字段名小写,下划线分割.
import org.hibernate.boot.model.naming.Identifier;import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;public class UpperTableStrategy extends SpringPhysicalNamingStrategy {@Overridepublic Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {// 将表名全部转换成大写String tableName = name.getText().toUpperCase();return Identifier.toIdentifier(tableName);}//将字段名转为大写-下划线隔开. 默认小写-下划线@Overridepublic Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {Identifier lowerName = super.toPhysicalSchemaName(name, jdbcEnvironment);String colnumName = lowerName.getText().toUpperCase();return Identifier.toIdentifier(colnumName);}}
application.yml
jpa:database: mysqlhibernate:naming:physical-strategy: com.topsoft.workflow.config.UpperTableStrategy
/wanthune/p/11104564.html