简体   繁体   English

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

[英]javax.persistence annotations missing optional elements?

We're in the process of upgrading our Play framework application from 2.3.10 to 2.4.8, and with that, upgrading from Ebean 3.x to 4.6.2. 我们正在将Play框架应用程序从2.3.10升级到2.4.8,并随之从Ebean 3.x升级到4.6.2。

I'm now seeing compilation errors, stating that some javax.persistence annotations are missing fields. 我现在看到编译错误,指出某些javax.persistence注释缺少字段。 Both versions of Ebean depend upon version 1.0 of javax.persistence . 这两个版本的Ebean都依赖于javax.persistence 1.0版本。

The strange thing is that IntelliJ is showing the annotations as missing the optional elements, but the Javadoc for the annotation mentions the optional element. 奇怪的是IntelliJ将注释显示为缺少可选元素,但是注释的Javadoc却提到了可选元素。 Note that compilation also fails in 请注意,编译也会失败

For example, here is the source that IntelliJ shows for javax.persistence.UniqueConstraint : 例如,这是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();
}

You are currently using JPA 1.0 (in your build process somewhere, and what IDEA shows you). 您当前正在使用JPA 1.0(在构建过程中的某个位置,以及IDEA会显示的内容)。 The "name" attribute of the UniqueConstraint annotation was introduced in JPA 2.0. JPA 2.0中引入了UniqueConstraint批注的“名称”属性。 You need to change the build of IDEA to use JPA 2.0. 您需要更改IDEA的版本才能使用JPA 2.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM