今天在使用SpringBoot整合Hibernate后创建表,表名为小写,而在linux下,mysql的表名是区分大小写的,因此在我的数据表中,就出现了两个一样的表
act_id_user 和 ACT_ID_USER
本来为设置了注解的表名是大写的
@Table(name="ACT_ID_USER")
经过查询资料发现,修改/etc/my.cnf的配置,使得mysql不区分大小写是无效的
最后发现,我们可以在 application.properties里面添加如下内容即可
spring.jpa.hibernate.naming.physical-strategy = cn.studyBoot.dao.strategy.UpperTableStrategy
UpperTableStrategy类的内容如下
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
public class UpperTableStrategy extends PhysicalNamingStrategyStandardImpl {
/**