title: Unable to delete entity in spring-hibernate
body: <p>I am using hibernate version 4.3.11.Final.
  When I try to delete a product from the jsp page, it enters the controller and executes it completely.
  However, it shows this message on the console : org.hibernate.event.internal.DefaultDeleteEventListener deleteTransientEntity
  INFO: HHH000114: Handling transient entity in delete processing</p>
  
  <p>Does anyone have a solution?</p>
  
  <p>This is my controller:</p>
  
  <pre><code>@RequestMapping("/deleteProduct")
      public ModelAndView delete(@ModelAttribute("product") Product product, BindingResult result)
      {
          System.out.println("In delete");
          productDAO.delete(product);
          System.out.println("Product Successfully deleted");
          return new ModelAndView("AdminProduct");
      }
  </code></pre>
  
  <p>This is my JSP:</p>
  
  <pre><code>&lt;c:forEach items="${products}" var="product"&gt;
                  &lt;tr
                      style="background-color: white; color: black; text-align: center;"
                      height="30px"&gt;
                      &lt;td&gt;&lt;c:out value="${product.p_id}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${product.p_name}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${product.p_desc}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;c:out value="${product.price}" /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;form:form action="deleteProduct" modelAttribute="product"&gt;
                              &lt;input type="submit" value="Delete" /&gt;
                          &lt;/form:form&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;form:form action="editProduct" modelAttribute="product"&gt;
                              &lt;input type="submit" value="Edit" /&gt;
                          &lt;/form:form&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/c:forEach&gt;
  </code></pre>
  
  <p>And, this is my DAOImpl class for this Entity:</p>
  
  <pre><code>package com.niit.shoppingcart.dao;
  
  import java.util.List;
  
  import javax.transaction.Transactional;
  
  import org.hibernate.Query;
  import org.hibernate.SessionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Repository;
  
  import com.niit.shoppingcart.model.Product;
  
  @Repository(value = "productDAO")
  public class ProductDAOImpl implements ProductDAO {
  
      @Autowired
      private SessionFactory sessionFactory;
  
      @Transactional
      public boolean save(Product product) {
          try {
              sessionFactory.getCurrentSession().save(product);
              return true;
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              return false;
          }
      }
  
      @Transactional
      public boolean update(Product product) {
          try {
              sessionFactory.getCurrentSession().update(product);
              return true;
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              return false;
          }
      }
  
      @Transactional
      public boolean delete(Product product) {
          try {
              sessionFactory.getCurrentSession().delete(product);
              return true;
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              return false;
          }
      }
  
      @Transactional
      public Product get(String id) {
          String hql = "from Product where id = " + " ' " + id + " ' ";
          Query query = sessionFactory.getCurrentSession().createQuery(hql);
          @SuppressWarnings("unchecked")
          List&lt;Product&gt; plist = (List&lt;Product&gt;) query.list();
  
          if (plist == null || plist.isEmpty()) {
              return null;
          } else {
              return plist.get(0);
          }
      }
  
      @SuppressWarnings("unchecked")
      @Transactional
      public List&lt;Product&gt; listAll() {
          String hql = "from Product";
          Query query = sessionFactory.getCurrentSession().createQuery(hql);
          return query.list();
      }
  
  }
  </code></pre>
  
  <p>This is the Entity class:</p>
  
  <pre><code>package com.niit.shoppingcart.model;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  import org.springframework.stereotype.Component;
  
  @Entity
  @Table(name = "PRODUCT")
  @Component
  public class Product {
  
      @Id
      private String p_id;
      private String p_name;
      private String p_desc;
      private int price;
  
      public String getP_id() {
          return p_id;
      }
  
      public void setP_id(String p_id) {
          this.p_id = p_id;
      }
  
      public String getP_name() {
          return p_name;
      }
  
      public void setP_name(String p_name) {
          this.p_name = p_name;
      }
  
      public String getP_desc() {
          return p_desc;
      }
  
      public void setP_desc(String p_desc) {
          this.p_desc = p_desc;
      }
  
      public int getPrice() {
          return price;
      }
  
      public void setPrice(int price) {
          this.price = price;
      }
  }
  </code></pre>