title: java.lang.IllegalArgumentException: attempt to create delete event with null entity
body: <p>Cann't delete/update items from database.This exception is coming when try to delete item
  And this form get a combo box value from MainCategory class and having a foreign key of MainCtegory.Is that the reason that not allow to delete/update.</p>
  
  <p>package com.auction management.entity;</p>
  
  <pre><code>import javax.persistence.Column;
  
  import javax.persistence.Entity;
  
  import javax.persistence.FetchType;
  
  import javax.persistence.GeneratedValue;
  
  import javax.persistence.GenerationType;
  
  import javax.persistence.Id;
  
  import javax.persistence.JoinColumn;
  
  import javax.persistence.ManyToOne;
  
  import javax.persistence.Table;
  
  @Entity
  
  @Table(name = "SubCategory")
  
  public class SubCategory {
  
      @Id
      @Column(name = "usbId",nullable = false,unique = true)
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int subid;
  
      @Column(name = "subName")
      private String subName;
  
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "id",nullable = false)
     private MainCategory mainCategory;
  
      public MainCategory getMainCategory() {
          return mainCategory;
      }
  
      public void setMainCategory(MainCategory mainCategory) {
          this.mainCategory = mainCategory;
      }
  
  
  
      public SubCategory() {
      }
  
      public int getSubid() {
          return subid;
      }
  
      public void setSubid(int subid) {
          this.subid = subid;
      }
  
      public String getSubName() {
          return subName;
      }
  
      public void setSubName(String subName) {
          this.subName = subName;
      }
  
  
  }
  
  
  
  
   public static boolean deleteSubCategory(int id){
  
          boolean status=false;
          Session session=HibernateUtil.getSessionFactory().openSession();
          Transaction transaction=null;
  
          try {
              transaction=session.beginTransaction();
            SubCategory subcategory=(SubCategory)session.get(SubCategory.class,id);
              session.delete(subcategory);
              transaction.commit();
              status=true;
  
          } catch (Exception e) {
              e.printStackTrace();
              transaction.rollback();
              status=false;
          }
          finally{
              session.close();
          }
          return  status;
      }
  
  
  
  
  
   private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) 
  { 
  
     boolean b=SubCategoryDao.deleteSubCategory(id);
  
          if(b)
          {
              JOptionPane.showMessageDialog(this,"Type Deleted Successfully");
                 Category=SubCategoryDao.getAllCategories();
                 fillTable();
                 clear();
          }else
          {
              JOptionPane.showMessageDialog(this,"Not Delete");
          }
  }
  
  
  
  
  private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {                                          
          String name=txtSubCategory.getText();
  
          SubCategory scategory=new SubCategory();
  
          scategory.setSubName(name);
          scategory.setSubid(id);
  
          SubCategoryDao.updateSubCategory(scategory);
          Category=SubCategoryDao.getAllCategories();
          fillTable();
          clear();
      }  
  </code></pre>