Labs

  1. Create a class in the com.example.jpavideostore.client package named JPQLLab (this is where you will complete the following steps).

  2. Create a method that uses JPQL to retrieve all Customers in the database whose id is between 100 and 110. Output their first name, last name, and email. (Hint: You can use the BETWEEN reserved word in JPQL just like SQL.)

  3. Modify your previous solution, using parameters to set the minimum and maximum ids instead of hard-coding them into the query String.

  4. Refactor your program into a method in the JPQLLab class named getRangeOfCustomers.

  5. the method should take two arguments (minId, maxId), both ints

  6. return the correct list of Customers given these inputs

  7. Create a new class in the test src folder named JPQLTest

    • Write a test to ensure that getRangeOfCustomers retrieves Customer objects within the correct range
  8. Write a method in the JPQLLab class named getCustomerEmailByName.

  9. the method takes two Strings as an argument (fname, lname)

  10. return either a single String, or null

  11. write a test to ensure that a Customer can be retrieved (choose a customer that exists to test)

  12. Write a method in the JPQLLab class named getFilmByTitle.

  13. the method takes one String as an argument (filmTitle)

  14. return either a single Film object, or null

  15. write a test to ensure that a Film can be retrieved.

  16. Write a method in the JPQLLab class named getFilmsTitlesByReleaseYear.

  17. the method takes one int as an argument (year)

  18. return the correct list of film titles (List<String>).

  19. write a test to ensure that the correct Film objects were retrieved.


Prev -- Up