我有一个父类:
@MappedSuperclass
public class BaseText implements Serializable {
@Column(name = "LOCALE_CODE", nullable = false)
private String localeCode;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@Index
@Column(name = "LOCALIZED_TEXT_ID", nullable = false)
@ForeignKey
private LocalizedText localizedText;
//getters and setters
}
和子类之一:
@Entity
@Table(name = "ASSESSMENT_TEXT")
@AttributeOverride(name = "localeCode", column = @Column(name = "LOCALE_CODE"))
@AssociationOverride(name = "localizedText", joinColumns = @JoinColumn(name = "LOCALIZED_TEXT_ID"))
public class AssessmentText extends BaseText {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@Index
@Column(name = "ASSESSMENT_ID", nullable = false)
@ForeignKey
private Assessment assessment;
//Getters and setters.
}
当我试图持久化一个对象时,我收到以下错误:
org.apache.openjpa.persistence.ArgumentException: Superclass field "java.lang.Object.localizedText" is mapped in the metadata for subclass "com.my.com.AssessmentText", but is not a persistent field.
是什么导致了这种情况以及如何解决?
我在 JUnit 中使用嵌入式 derby 数据库,JPA 实现是 OpenJPA。