从Java 8迁移到Java 11时,JPA/Eclipselink错误



我正在尝试将我的Thorntail应用程序从Java 8迁移到Java 11,而我在实体的关系方面遇到了问题。二手映射与Java 8合作正常,但是在Java 11中,我有一个错误:

2019-07-03 15:48:12,713 ERROR [stderr] (main) Exception Description: 
  Predeployment of PersistenceUnit [p-unit] failed.
2019-07-03 15:48:12,713 ERROR [stderr] (main) Internal Exception: 
  Exception [EclipseLink-7250] (Eclipse Persistence Services - 
   2.7.3.v20180807-4be1041): 
    org.eclipse.persistence.exceptions.ValidationException
2019-07-03 15:48:12,713 ERROR [stderr] (main) Exception Description: 
  [class com.mytest.data.specific.entities.Table3] uses a non-entity 
   [class com.mytest.data.specific.entities.Table2] as target entity 
     in the relationship attribute [field table2].

我的实体映射就是这样:

@MappedSuperclass
public abstract class AbstractIdEntity extends AbstractEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;
    public Long getId() {
        return id;
    }
    protected void setId(final Long id) {
        this.id = id;
    }
}
@Entity
@Table(name = "table_2")
public class Table2 extends AbstractIdEntity {
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "table_1_id", referencedColumnName = "id")
    private Table1 table1;
    @Column(name = "some_info", nullable = false)
    private String someInfo;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "table_2_id")
    private List<Table3> table3List;
//more stuff
}
@Entity
@Table(name = "table_3")
public class Table3 extends AbstractIdEntity {
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "table_2_id", referencedColumnName = "id")
    private Table2 table2;
    @Lob
    @Column(name = "some_bytes", nullable = false)
    private byte[] someBytes;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "table_3_id")
    private List<Table4> table4List;
//more stuff
}

我试图删除子对父母的引用,但是EntityManager找不到任何定义的NamedQuery。我尝试的另一件事是切换到冬眠,这些映射有效,但在实体方面存在一些问题。

我正在使用thorntail v2.4.0. -final和eclipselink v2.7.3。

有人有什么线索吗?

我在一个小型项目中创建了一个类似的层次结构,并将其上传到GitHub,如果有人想仔细观察 -> githubproject。

这是一个奇怪的例外。我不知道它是否会修复它,但是您的@OneToMany映射应使用mappedBy属性,而不指定@JoinColumn s。例如,Table3.table2应该像这样映射:

    @OneToMany(mappedBy="table2", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Table3> table3List;