Hibernate and trying to build simple feature where we can search Product by Id. Hibernate has inbuit function to search an entity by its id. I tried the same but i am getting "java.lang.NoSuchMethodException" .
MyController.java :
@GetMapping(value = "/getProducts/{id}" , produces ="application/json")
public ResponseEntity<Product> display(@PathVariable int id) {
Product products = productServiceImp.getAllProducts(id);
return ResponseEntity.ok(products);
MyProductServiceImp:
@Override
public Product getAllProducts(int product_id ) {
return productRepository.getById(product_id );
}
MyProductRepository:
@Repository
public interface ProductRepository extends JpaRepository<Product, Integer> {
}
Schema of Product table : (product_id, desciption,display_name, qty, amount)
When i try to invoke API by postman
curl --location --request GET 'http://localhost:8080/admin/getProducts/1.
I see it is Caused by: java.lang.NoSuchMethodException: com.Project.OrderProcessing.OrderProcessing.Entity.Product$HibernateProxy$zAdAYVvM.<init>().I am unable to understand reason behind it
/Admin/getProducts/1instead of just/getProducts/1?@RequestMappingfor/adminon the class