From the course: Creating Spring Boot Microservices

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Solution: Create a JPQL query method

Solution: Create a JPQL query method - Spring Boot Tutorial

From the course: Creating Spring Boot Microservices

Solution: Create a JPQL query method

(upbeat music) - [Instructor] Did you figure it out? The full answer will be in branch 03_08, but I'm just going to code it right in front of us now so you understand completely. So I'm going to add a new method called List Tour findByDifficulty. And this is kind of nice because I've installed the Spring Boot extension, it auto-populates with IntelliSense the attribute that is allowed. But if you don't have that, that's okay. So findByDifficulty because on a tour, there is a difficulty attribute, so we just say findByDifficulty and use camel case on there. So I need to include that import. And the next one is Tour findByTourPackage. Let's look at the attributes of the tour again. So we have a TourPackage attribute, but we want to find it by the code. So if we drill down into TourPackage, there's the code attribute. So if we just chain them together following camel case rules, so TourPackageCode, passing in the string for the code, and that's the proper syntax. So let's invoke the…

Contents