简体   繁体   中英

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.

I'm now seeing compilation errors, stating that some javax.persistence annotations are missing fields. Both versions of Ebean depend upon version 1.0 of javax.persistence .

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. Note that compilation also fails in

For example, here is the source that IntelliJ shows for 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). The "name" attribute of the UniqueConstraint annotation was introduced in JPA 2.0. You need to change the build of IDEA to use JPA 2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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