I'm trying to migrate my Thorntail application from java 8 to java 11 and I am having problems with entity's relationships. The used mapping works fine with java 8 but in java 11 i have this error:
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].
My Entity mapping is like this:
@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
}
I tried to remove the child reference to the parent but then the EntityManager
won't find any defined NamedQuery
. Other thing I tried was to switch to hibernate and this mappings works but had some problems persisting the entities.
I am using Thorntail v2.4.0.Final and Eclipselink v2.7.3.
Does anyone have any clue of what might be the problem?
I created a similar hierarchy in a small project and uploaded it to github if anyone wants to take a closer look -> githubProject.