javax.persistence 注释缺少可选元素?

javax.persistence annotations missing optional elements?

我们正在将我们的 Play 框架应用程序从 2.3.10 升级到 2.4.8,同时从 Ebean 3.x 升级到 4.6.2。

我现在看到编译错误,指出某些 javax.persistence 注释缺少字段。 Ebean 的两个版本都依赖于 javax.persistence.

的 1.0 版

奇怪的是 IntelliJ 将注释显示为缺少可选元素,但注释的 Javadoc 提到了可选元素。请注意,编译在

中也会失败

例如,这是 IntelliJ 为 javax.persistence.UniqueConstraint 显示的来源:

/**
 * This annotation is used to specify that a unique constraint 
 * is to be included in the generated DDL for a primary or secondary table.
 *
 * <pre>
 *    Example:
 *    &#064;Entity
 *    &#064;Table(
 *        name="EMPLOYEE", 
 *        uniqueConstraints=
 *            &#064;UniqueConstraint(columnNames={"EMP_ID", "EMP_NAME"})
 *    )
 *    public class Employee { ... }
 * </pre>
 *
 * @since Java Persistence 1.0
 */
@Target({TYPE}) 
@Retention(RUNTIME)

public @interface UniqueConstraint {

    /** (Required) An array of the column names that make up the constraint. */
    String[] columnNames();
}

您目前正在使用 JPA 1.0(在您的构建过程中的某个地方,以及 IDEA 向您显示的内容)。 UniqueConstraint annotation 的 "name" 属性是在 JPA 2.0 中引入的。您需要更改 IDEA 的构建以使用 JPA 2.0。