title: EnitityManager remove - IllegalArgumentException: Unknown entity: java.lang.Integer] with root cause
body: <p>I did this example while learning spring and everything worked, now I'm writing my own project and I don't understand why I'm getting ERROR: Unknown entity: java.lang.Integer when I try to perform a remove operation from the EntityManager class to remove an object from the MySQL database</p>
  
  <p>Product class (i don't paste here all methods like getters and setters etc.)</p>
  
  <pre class="lang-java prettyprint-override"><code>import javax.persistence.*;
  
  @Entity
  public class Product {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer id;
  
      private String name;
  
      @OneToOne
      private ProductType type;
  
      private float price;
  
      private String description;
  
      //more code...
  }
  </code></pre>
  
  <p>ProductRepository (i show only delete method)</p>
  
  <pre class="lang-java prettyprint-override"><code>import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import javax.transaction.Transactional;
  
  public class DBProductRepository implements ProductRepository{
      @PersistenceContext
      private EntityManager entityManager;
  
      @Override
      @Transactional
      public void deleteProduct(Integer id) {
          entityManager.remove(id);
      }
  
      //more code...
  }
  </code></pre>
  
  <p>ProductService (i show only delete method)</p>
  
  <pre class="lang-java prettyprint-override"><code>@Service
  public class ProductService {
      public void deleteProduct(Integer id) {
          productRepository.deleteProduct(id);
      }
      //more code...
  }
  </code></pre>
  
  <p>ProductController</p>
  
  <pre class="lang-java prettyprint-override"><code>@Controller
  public class ProductController {
      @RequestMapping("/products")
      public String getProducts(Model model){
          List&lt;Product&gt; products = productService.getAllProducts();
          model.addAttribute("products",products);
          return "products";
      }
  
      @RequestMapping(value="/product/delete/{id}")
      public String deleteProduct(@PathVariable("id") Integer id){
          productService.deleteProduct(id);
          return "redirect:/products";
      }
      //more code...
  }
  </code></pre>
  
  <p>products.html</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;title&gt;Product list&lt;/title&gt;
      &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"/&gt;
  
      &lt;link rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}"/&gt;
  
      &lt;script th:src="@{/webjars/jquery/3.4.1/jquery.min.js}"&gt;&lt;/script&gt;
      &lt;script th:src="@{/webjars/bootstrap/4.3.1/js/bootstrap.min.js}"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container"&gt;
      &lt;table class="table"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;td&gt;Id&lt;/td&gt;
              &lt;td&gt;Type&lt;/td&gt;
              &lt;td&gt;Name&lt;/td&gt;
              &lt;td&gt;Price&lt;/td&gt;
              &lt;td&gt;Description&lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;tr th:each=" product : ${products}"&gt;
              &lt;td th:text="${product.id}"&gt;&lt;/td&gt;
              &lt;td th:text="${product.type}"&gt;&lt;/td&gt;
              &lt;td th:text="${product.name}"&gt;&lt;/td&gt;
              &lt;td th:text="${product.price}"&gt;&lt;/td&gt;
              &lt;td th:text="${product.description}"&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a th:href="${'/product/delete/'+product.id}"&gt;Delete&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When i click delete on site localhost:8080/products i got:
  "Whitelabel Error Page</p>
  
  <p>This application has no explicit mapping for /error, so you are seeing this as a fallback.
  Mon Sep 16 17:41:45 CEST 2019
  There was an unexpected error (type=Internal Server Error, status=500).
  Unknown entity: java.lang.Integer"</p>
  
  <p>In console:
  "2019-09-16 17:41:45.175 ERROR 7792 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Unknown entity: java.lang.Integer] with root cause"</p>
  
  <p>What am i doing wrong?</p>