eclipselink:不可编译的元模型类,生成时存在notnull over byte字段

hmtdttj4  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(257)

我拥有以下实体:

  1. import javax.persistence.Column;
  2. import javax.persistence.Entity;
  3. import javax.persistence.Table;
  4. import javax.persistence.Version;
  5. import javax.validation.constraints.NotNull;
  6. @Entity
  7. @Table(name = "authentication_certificate")
  8. public class Certificate {
  9. @Column(name = "body", nullable = false)
  10. @NotNull
  11. private byte[] body;

生成的元模型类代码为:

  1. package bm.authentication;
  2. import @javax.validation.constraints.NotNull byte;
  3. import javax.annotation.processing.Generated;
  4. import javax.persistence.metamodel.SingularAttribute;
  5. import javax.persistence.metamodel.StaticMetamodel;
  6. @Generated(value="org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor", date="2020-11-20T16:29:34", comments="EclipseLink-2.7.6.v20200427-rNA")
  7. @StaticMetamodel(Certificate.class)
  8. public class Certificate_ extends UuidIdEntity_ {
  9. ...
  10. public static volatile SingularAttribute<Certificate, NotNull byte[]> body;
  11. ...

如您所见,生成的行

  1. import @javax.validation.constraints.NotNull byte
  2. ..
  3. public static volatile SingularAttribute<Certificate, NotNull byte[]> body;

不要编译。。
当我删除@notnull注解时,代码会正确生成,但是我失去了在这些字段上使用java验证api的能力。我意识到这个问题只发生在二进制类型上,我可以在其他类型的字段中保留@notnull。
一些有用的附加信息我使用eclipselink-2.7.4/eclipselink-2.7.6从fish.payara.extras/payara-embedded-all从payara 5导入,作为从payara 4迁移的一部分。在payara 4代码中工作正常。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题