Labs

  1. Create a class CRUDClient in your com.example.jpavideostore.client package.

  2. You will be writing JPQL queries to manipulate data and will need to set up an EntityManagerFactory as well as an EntityManger.

  3. Create a method updateNullEmails

  4. In a terminal write a SQL query to display all customers that have null or empty string emails.
  5. This method should find all of the Customer records who have no email addresses (empty string or null values) and update them with a new email whose format is firstname.lastname@sdcustomer.org.
  6. In a main, call this method.
  7. Check the database to make sure the changes were made.

  8. Create a method addNewAddress

  9. This method should create a new Address object, and set its values to your personal information (street, city, state, postalCode, phone).
  10. Persist your Address object.
  11. Print out the object.
  12. In a main, comment out the call to updateNullEmails and run this method.
  13. Check to make sure the new Address was added to the database.

  14. Create a method called deleteAddress

  15. This method should take a address's id as a parameter.
  16. Write the logic to delete a Address from the database based on its id.
  17. In a main, comment out the call to addNewAddress and run your method, passing in the id value of the Address you created previously.
  18. Check the database to make sure the Address was deleted.

Prev -- Up