title: Remove/Find Nodes in hierarchical table of JPA Hibernate
body: <p>I have created a table to store hierarchical data for a purpose.
  In LEAF column Its there to decide whether its a leaf. And PARENT_ID column is for checking which one is the parent of the node. Below is the Database Table.</p>
  
  <pre><code>CREATE TABLE info
  (
    id bigint NOT NULL,
    leaf bigint,
    "name" character varying(255),
    parent_id bigint,
    "value" character varying(255),
    "info" character varying(255),
    CONSTRAINT info_pkey PRIMARY KEY (id)
  )
  </code></pre>
  
  <p>TABLE NAME: info</p>
  
  <pre><code>ID LEAF  NAME PARENT_ID VALUE  INFO
  -- ----  ---- ------    -----  ----
  1   0    ROOT  0        ''     '' 
  2   0     S2   1        ''     ''
  3   0     S3   1        TEST1  INFO1
  4   1     S4   1        TEST2  ''
  5   1     S5   2        ''     ''
  6   0     S6   3        ''     ''
  8   1     S8   6        P8     ''
  </code></pre>
  
  <p>I'm using JPA Hibernate with PostgreSQL in my project, this is the only table with data. and it has no relation to any other table.</p>
  
  <p><strong>Q1)</strong> If I want to delete "S3" how should I do that, since It has "S6" as a child and "S8" is a child of "S6". So It needs to be cascaded on update when I delete "S3". How can I do this in JPQL or Hibernate NativeQuery in JAVA?</p>
  
  <p><strong>Q2)</strong> How can I find children and leaf of a specific Parent Node?</p>