title: What's the possible reason for this IllegalArgumentException?
body: <p>I'm trying to update a value via PUT request. There seems to be an IllegalArgumentException/TypeMismatchException which I can't seem to figure out why.</p>
  
  <p><strong>Here's the <em>Product</em> model class:</strong></p>
  
  <pre><code>@Table(name="product")
  public class Product {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
      private String name;
      private int price;
      private String vendor;
      private String description;
      private Boolean returnPolicy;
  </code></pre>
  
  <p><strong>Here's the ProductController code for PUT method:</strong></p>
  
  <pre><code>@Autowired
  private ProductService productService;
  
  @RequestMapping(method = RequestMethod.PUT, value = "/products/{id}")
  public void updateProduct(@RequestBody Product product, @PathVariable int id) {
      res = productService.updateProduct(product, id);
      System.out.println(res ? "Successful" : "Unsuccessful");
  }
  </code></pre>
  
  <p><strong>Here's the updateProduct method for updating the product:</strong></p>
  
  <pre><code>public Boolean updateProduct(Product product, int id) {
      if(productRepository.findById(Integer.toString(id)) != null) {
          productRepository.save(product);
          return true;
      }
          return false;
  }
  </code></pre>
  
  <p><strong>Here's my ProductRepository class:</strong></p>
  
  <pre><code>import org.springframework.data.repository.CrudRepository;
  import org.springframework.stereotype.Repository;
  
  import testing.poc.models.Product;
  
  @Repository
  public interface ProductRepository extends CrudRepository&lt;Product, String&gt;{
  
  }
  </code></pre>
  
  <p><strong>This is the URL for my PUT request via Postman:</strong></p>
  
  <blockquote>
    <p><a href="http://localhost:8080/products/8" rel="nofollow noreferrer">http://localhost:8080/products/8</a></p>
  </blockquote>
  
  <p><strong>This is the entry in the DB that I'm trying to update:</strong>
  <img src="https://i.imgur.com/zkqapYW.png" alt="entry"></p>
  
  <p>The message I'm getting is as follows:</p>
  
  <blockquote>
    <p>{
        "timestamp": "2019-03-27T13:53:58.093+0000",
        "status": 500,
        "error": "Internal Server Error",
        "message": "Provided id of the wrong type for class testing.models.Product. Expected: class java.lang.Integer, got class java.lang.String; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class testing.models.Product. Expected: class java.lang.Integer, got class java.lang.String",
        "path": "/products/8"
    }</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>org.hibernate.TypeMismatchException: Provided id of the wrong type for class testing.models.Product. Expected: class java.lang.Integer, got class java.lang.String</p>
  </blockquote>
  
  <p>I don't understand how a String type is being supplied when I've declared 'id' as int everywhere. How can this be fixed?</p>