陈杨华*_*陈杨华 2 java hibernate spring-data-jpa
我将实体UserInfoEntity、变量名称从“moblie”更改为“mobile”,然后重新启动服务器。当我查看表格时,我发现表格没有删除“移动”列。这是我的实体变化;
由此;
@Entity
@Table(name = "pe_userinfo")
public class UserInfoEntity {
private String moblie;
}
Run Code Online (Sandbox Code Playgroud)
对此;
@Entity
@Table(name = "pe_userinfo")
public class UserInfoEntity {
private String mobile;
}
Run Code Online (Sandbox Code Playgroud)
用于auto-ddl=create-drop完全删除有问题的架构并使用固定的列值重新创建它,您不能以这种方式更新架构。
还要检查Hibernate: hbm2ddl.auto=update in production? ,正如它所说,最好由您自己手动处理此类情况,而不是使用 Hibernate 来处理现有架构上的此类修改。
额外的想法
如果您想保存您的数据;
pe_userinfo_temppe_userinfo_temppe_userinfo->复制数据pe_userinfo-temppe_userinfo从数据源手动删除表pe_userinfo,自动 ddl 将创建它但将为空pe_userinfo_temp-> new复制数据pe_userinfope_userinfo_temp从源代码中删除并从数据源中删除| 归档时间: |
|
| 查看次数: |
7427 次 |
| 最近记录: |