Using 5.2.12.Final. I have a simple main class that creates an EntityManager instance to validate my mappings (and create the schema).
I have a parent table (Applicant) that has a child table (ProofDocument). The latter of which is abstract and has the @DiscriminatorColumn and @DiscriminatorOptions annotations.
ProofDocument has two descendants: ProofDocumentId and ProofDocumentSsn.
The @OneToMany linkages from Applicant look like this:
Code:
@Fetch(FetchMode.SELECT)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "applicant", orphanRemoval = true)
@Where(clause = "IDPR_PROOF_TYP = '2 '") // needs trailing space
public List<ProofDocumentId> getProofDocumentIdCollection() {
return proofDocumentIdCollection;
}
@Fetch(FetchMode.SELECT)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "applicant", orphanRemoval = true)
@Where(clause = "IDPR_PROOF_TYP = '1 '") // needs trailing space
public List<ProofDocumentSsn> getProofDocumentSsnCollection() {
return proofDocumentSsnCollection;
}
(Setters removed for brevity.)
The ancestor ProofDocument references the Applicant (parent) like so:
Code:
@JoinColumn(name = "IDPR_PERSON_ID", insertable = false, nullable = false, updatable = false,
foreignKey = @ForeignKey(name = "fk_pod_a__person_id"))
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@NotNull(message = "proofDocument.applicant.required")
public Applicant getApplicant() {
return applicant;
}
ProofDocument is abstract because an instance of it makes no sense, only an instance of the descendants is valid.
So, why am I getting:
Code:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: a.b.c.ProofDocumentId.applicant in a.b.c.Applicant.proofDocumentIdCollection
when it is clearly in the ancestor class of ProofDocumentId/Ssn. I should
NOT have to move Applicant from ancestor to descendant to clear this error, but that's what I had to do.