From the course: Spring Web MVC 6
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Add repository and Controller methods - Spring Tutorial
From the course: Spring Web MVC 6
Add repository and Controller methods
- [Instructor] The next part of this use case is to work on the product details flow. So the first step is to add a method in the ProductRepository to get product details specific to a product id. So on the ProductRepository class, let's open that. And we are just going to add a method, very similar to searchByName that we added on line 15. So I'll just grab these two lines, lines 14 and 15, copy them, come down there and paste it. And this time this is only one product that you're going to get because you are trying to search by the id. So it's not going to be a list of products. So let's change that return type. The name should be searchById because that's what we want to do. And the parameter will be id in this case. And the Query on line 20 should change to select p from Product p where p.id, and we are not going to use the like clause, we'll use a perfect match with the help of the equal to operator. And this…
Contents
-
-
-
-
-
-
-
Introduction to interceptors4m 38s
-
(Locked)
Add to cart use case overview1m 28s
-
(Locked)
Add and register an interceptor class3m 42s
-
(Locked)
Add repository and Controller methods3m 25s
-
(Locked)
Map attributes on the product details page8m 39s
-
(Locked)
Add a session in the interceptor6m 3s
-
(Locked)
Implement add to cart in Controller12m 39s
-
(Locked)
Display the number of items in the cart4m 4s
-
(Locked)
Error mapping pages5m 27s
-
(Locked)
Add a custom error handler8m 29s
-
-
-