title: ON DELETE SET NULL ON UPDATE SET NULL using JPA
body: <p>How do i add <strong>ON DELETE SET NULL ON UPDATE SET NULL</strong> Constraint while creating the table using JPA . Below the entity definition</p>
  
  <p>table </p>
  
  <pre><code>CREATE TABLE `node` (
    `id` bigint(20) NOT NULL,
    `parentNode_id` bigint(20) default NULL,
    PRIMARY KEY  (`id`),
    KEY `FK1EC1DD0F28AB6BA5` (`parentNode_id`),  
    CONSTRAINT `FK1EC1DD0F28AB6BA5` FOREIGN KEY (`parentNode_id`) REFERENCES `node` (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  
  
  @Entity
  public class Node {
  
      @Id
      @GeneratedValue(strategy = GenerationType.TABLE, generator = "NodeSequence")
      private long id;
  
      @ManyToOne(cascade=CascadeType.REMOVE)
      @JoinColumn(name = "parentNode_id", nullable = true)
      protected Node parentNode = null;
  
  }
  </code></pre>