Exercise 10: JPQL - jkneal/spring-angular-train GitHub Wiki
Goals
Our store API has a few methods which we have not implemented yet and we will now implement the first: finding all stores. We will use JPQL and a named query to implement this method.
Instructions
-
Review the new tests in the
StoreRepositoryTestclass. Execute them to make sure the new tests still fail. -
Implement the
findAllmethod in theJpaStoreRepository. Use JPQL to create a new query which will return all stores in the database. -
Run the tests again to verify that the
testFindAlltest now passes -
Now that you have created the query directly in your repository convert it into a named query on our
Storeclass -
Refactor the
findAllmethod in theJpaStoreRepositoryclass to use the new named query -
Run the tests again to verify that the
testFindAlltest still passes
Verification
- The test cases will pass when the exercise is complete