春季启动,休眠 - 创建-删除使用旧模式



我有Spring boot,Spring data,hibernate和ms sql, 但是使用create-drop策略,Hibernate基于我的@Entity类的旧实现创建表。

实体类如下:

@Entity
public class User {
@Id
@GeneratedValue
private int id;
@Column(unique = true, nullable = false)
private String name;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private String email;
@Column(nullable = false)
private boolean active = false;
@Column
private String activationUUID = UUID.randomUUID().toString();
//getters and setters
}

在应用程序属性中,相关配置:

spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=create-drop

但是我在 stdout 中看到的,一旦我运行我的应用程序:

2018-03-17 12:08:10.973  INFO 876 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.SQLServer2008Dialect
2018-03-17 12:08:11.473  INFO 876 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
Hibernate: drop table [user]
Hibernate: create table [user] ([id] int identity not null, [account_activationuuid] varchar(255), [account_active] bit not null, [email] varchar(255) not null, [name] varchar(255) not null, [password] varchar(255) not null, [registration_date] datetime2 not null, primary key ([id]))
Hibernate: alter table [user] add constraint UK_gj2fy3dcix7ph7k8684gka40c unique ([name])
2018-03-17 12:08:11.488  INFO 876 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete

请注意,我删除了@Columnregistration date,将accountActivationUUID重命名为activationUUID,并将accountActive重命名为active

尽管如此,我在标准输出中看到旧模式,它甚至像这样存储在数据库中。

所以,我的问题:
1)这个旧模式从何而来?
2)休眠有一些模式缓存吗?
3)如何让它每次都生成新的模式 - 在我的代码中完全表示@Entity类?
4)为什么说在stdout中使用2008年方言,即使我在application.properties中指定了2012年方言?

我尝试使 intelj 中的缓存失效,重新启动计算机和数据库,以在硬盘驱动器上使用旧模式定义搜索文件,但都不起作用。

感谢您的任何回复:)

我发现了问题并设法使其工作。

问题出在pom.xml,有一些重复项和一些不存在的依赖项,所以运行只是下降到最新的成功运行。 这就是它使用旧模式的方式。

最新更新