我正在使用Gradle,所以要覆盖Hibernate版本,我添加了以下行:
ext['hibernate.version']="5.1.0.Final"
我遵循了SpringBoot 1.3.0支持hibernate 5的步骤
我正在使用下面的命名策略
spring.jpa.properties.hibernate.naming.implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.properties.hibernate.naming.physical_strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
我有一个实体类
@Entity
public class AppUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Length(max = 100)
private String username;
@NotNull
@Length(max = 100)
private String firstName;
@NotNull
@Length(max = 100)
private String lastName;
@Length(max = 100)
private String middleName;
@NotNull
@Length(max=100)
private String email;
@NotNull
@Length(max = 100)
private String password;
@NotNull
private boolean enabled;
}
在 Hibernate 4.x 中,它执行查询。
create table app_user (
id bigint not null auto_increment,
email varchar(100) not null,
enabled bit not null,
first_name varchar(100) not null,
last_name varchar(100) not null,
middle_name varchar(100),
password varchar(100) not null,
username varchar(100) not null,
primary key (id)
)
在5.x版本中,它执行了查询操作。
create table AppUser (
id bigint not null auto_increment,
email varchar(100) not null,
enabled bit not null,
firstName varchar(100) not null,
lastName varchar(100) not null,
middleName varchar(100),
password varchar(100) not null,
username varchar(100) not null,
primary key (id)
)
如何设置命名策略,使Hibernate在表名和列名上使用5.x下划线(与4.x相同)
ext['hibernate.version']="5.1.0.Final"
将Hibernate版本更改为5.1.0吗?我认为你参考的链接中的解决方案适用于Maven,而不适用于Gradle。 - TheKojuEffect