I have a top level Entity that contains a set of parent entities (@OneToMany).
I also want in that top level entity a set of child entities. The mapped by field is stored in the parent table so when I do this on the child i get
Top level entity with sets
Code:
@Entity
@Table(name = "DOC")
public class Doc implements java.io.Serializable {
.
private Set<TextItem> textItems = new HashSet<TextItem>(0);
private Set<TextItemCharValue> textItems = new HashSet<TextItemCharValue>(0); // try to map child entities
.
.
// THIS WORKS, gives me a set of all TextItems
@OneToMany(fetch = FetchType.LAZY, mappedBy = "doc", cascade = CascadeType.ALL)
public Set<TextItem> getTextItems() {
return this.textItems;
}
.
.
// DEPLOY ERROR, cannot get a set of children items
@OneToMany(fetch = FetchType.LAZY, mappedBy = "doc", cascade = CascadeType.ALL)
public Set<TextItemCharValue> getTextItemChars() {
return this.textItemChars;
}
Text Item entity (Parent class)
Code:
@Entity
@Table(name = "TEXTITEM")
@Inheritance(strategy = InheritanceType.JOINED)
public class TextItem implements java.io.Serializable {
private long textItemId;
private Doc doc;
Child entity of TextItem
Code:
@Entity
@Table(name="TEXTITEM_CHR_VALUE")
public class TextItemCharValue extends TextItem {
private String value;
Code:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: test.TextItemCharValue.doc in test.Doc.textItemChars
Any ideas on how to get a set of my child items. Seems like this should work because a TextItemCharValue IS A TextItem and TextItem does have a doc field.