我感兴趣的是hibernate.hbm2ddl.auto = validate实际上是如何工作的,我很难找到全面的文档.
我们最近发现生产系统受到http://opensource.atlassian.com/projects/hibernate/browse/HHH-3532的影响(Hibernate在名称上匹配外键,而不是签名,所以会为你重新创建它们)和hibernate .hbm2ddl.auto =正在从我们的下一个版本中删除更新.
我很乐意完全摆脱hibernate.hbm2ddl.auto并自己管理我们的数据库.但是,并非所有同事都分享这个世界观,有些人热衷于在hibernate.hbm2ddl.auto = validate中添加.
我担心这会遇到同样的问题,我有兴趣找到有关此验证实际工作原理的更多文档.Hibernate社区文档(http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html)实际上只是引用了这些值.
有没有人有任何好的文档指针,或在生产系统中使用验证的任何实际经验?
我使用Spring 4.3.3.RELEASE,Hibernate 5.2.2.Final,数据库是MySQL.我想尝试策略= GenerationType.TABLE.据我所知,GenerationType.SEQUENCE 我需要数据库中的序列来生成id.
这是我的实体.
@Entity(name = CommentTable.TABLE_NAME)
public class Comment {
private Integer id;
private String title;
private String message;
private LocalDateTime createdDateTime;
private Issue issue;
public Comment() {
}
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = CommentTable.COLUMN_ID, unique = true, nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
//Other getters and setters.
}
Run Code Online (Sandbox Code Playgroud)
Spring注释配置
@Configuration
@ComponentScan("com.ita.training.otm")
@ImportResource("classpath:/config.xml") // XML with DataSource bean
@EnableTransactionManagement
public …Run Code Online (Sandbox Code Playgroud)