如何为索引指定名称(@Column(unique = true))SQL Server 2005(How to specify a name for index (@Column(unique = t

编程入门 行业动态 更新时间:2024-10-10 23:26:49
何为索引指定名称(@Column(unique = true))SQL Server 2005(How to specify a name for index (@Column(unique = true)) SQL Server 2005)

唯一约束由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.

更多推荐

本文发布于:2023-07-27 15:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1292362.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:何为   索引   名称   Column   unique

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!