title: JPA Self Join using JoinTable
body: <p>I have 1 entity call Item in which I want to be able to link parent items to children.  to use a join table to create a parent/child relationship.  I haven't been able to get any good documentation on.  So if anyone has any thoughts I'm all ears.</p>
  
  <p>Here is what I have... which works most of the time.</p>
  
  <pre><code>public class Item implements java.io.Serializable {
       @Id
       private Long id;
  
       @ManyToOne(optional = true, fetch = FetchType.LAZY)
       @JoinTable(name = "ITEMTOITEM", joinColumns = { @JoinColumn(name = "ITEMID") }, inverseJoinColumns = { @JoinColumn(name = "PARENTITEMID") } )
       private Item parent;
  
       @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
       private List&lt;Item&gt; children;
  }
  </code></pre>
  
  <p>At times when I want to bring back objects that are tied to this item table I am getting an error of the following:</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.engine.ActionExecutionException: Exception thrown executing [AnnotatedAction@6669ff5 targetAction = com.assisted.movein.web.common.nav.NavAction@6edf74b7, attributes = map['method' -&gt; 'handleEntry']] in state 'oneTimeChargesAndFeesView' of flow 'in-flow' -- action execution attributes were 'map['method' -&gt; 'handleEntry']'; nested exception is Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
  Internal Exception: java.sql.SQLException: ORA-00904: "PARENTITEM_ITEMID": invalid identifier
  
   Error Code: 904
   Call: SELECT ITEMID, ITEMSHORTDESC, EFFENDDATE, ITEMDESC, PARENTITEM_ITEMID,  ITEMTYPECODE FROM ITEM WHERE (ITEMID = ?)
      bind =&gt; [1250]
  Query: ReadObjectQuery(com.domain.Item)
  </code></pre>
  
  <p>Any help would be appreciated.</p>