@org.hibernate.annotations.ForeignKey
已被弃用,但我找不到任何示例 JPA 2.1 等效项的外观?
@ManyToOne
@ForeignKey(name = "FK_USER") //@deprecated Prefer the JPA 2.1 introduced {@link javax.persistence.ForeignKey} instead.
private User user;
如果没有弃用的注解如何实现?
最佳答案
作为 the documentation表示,此注解不能应用于任何东西:
@Target(value={})
因此它只能用作另一个注释的一部分(列在另见部分):
@JoinColumn(foreignKey = @ForeignKey(name = "FK_USER"))
关于java - 如何命名自 JPA 2.1 以来的 ManyToOne 引用的外键约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23007356/