-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Access child data via mapped by?
PostPosted: Mon Dec 21, 2009 3:54 pm 
Beginner
Beginner

Joined: Mon Dec 21, 2009 3:43 pm
Posts: 24
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.