Spring boot jpa @Column命名大小写问题

时间:2023-11-28 12:20:14

一、问题

驼峰命名会被自动转成数据库下划线命名,指定@Column的name也不起作用

举例:

@Column(nullable = false,name = "resolvedDate")
private Timestamp resolvedDate;

resolvedDate会被转成resolved_date

二、解决方案

添加命名规则

在application.properties添加jpa属性:

spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl