I am looking into creating a class in such a way that it can hold references to 
itself and a parent.  In other words, I am looking to make a bi-directional 
tree of these classes.

The class would like something like this:
@Entity
  | @Table(name="sample")
  | public class Sample {
  |   private String id;
  |   private Sample parent;
  |   private Set<Sample> children;
  | 
  |   @Id
  |   @Column(name="id");
  |   public String getId(){ return id; }
  |   public void setId(String id) { this.id=id; }
  | 
  |   /** This is where I am confussed....  **/
  | }

The proposed table for the above would be:
varchar(256) id
  | varchar(256) parentId

I have made plenty of classes that reference one-to-many one way, and 
many-to-one the other, but this is the first time I have tried to make these 
connections within the same class.  I guess I am just getting confused how to 
setup the JoinColumn name and the mappedBy in the annotations to work off a 
single table column within a single table.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163697#4163697

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163697
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to