唯一约束由Sql Server 2005/2008中的唯一索引实现,如下所示:
@Column(name = "SOME_ID", unique = true) public String getSomeId() { return someId; }Sql Server生成UQ__USERS__135061FE4316F928 ,是否可以从hibernate指定用户定义的名称?
@Column没有name = XYZ 。 @org.hibernate.annotations.Index确实有一个name但在这种情况下我找不到指定唯一索引的方法。
我正在使用JPA / Hibernate 4.1.9,SQL Server 2008
Unique constraint is implemented by unique index in Sql Server 2005/2008 for the following:
@Column(name = "SOME_ID", unique = true) public String getSomeId() { return someId; }Sql Server generates UQ__USERS__135061FE4316F928, is it possible to specify a user defined name from hibernate?
There is no name = XYZ for @Column. @org.hibernate.annotations.Index does have a name however, I couldn't find a way to specify a unique index in that case.
I'm using JPA/Hibernate 4.1.9, SQL Server 2008
最满意答案
它是一个已知的问题,正如本jira的评论中所讨论的那样。 HB-1245的解决方法是导出模式并调整DDL以添加约束名称。
Its a known issue and as discussed in the comments of this jira. HB-1245 the work around would be to export the schema and tweak the DDL to add the constraint names.
更多推荐
发布评论