Labs
-
Create a class
CRUDClientin yourcom.example.jpavideostore.clientpackage. -
You will be writing JPQL queries to manipulate data and will need to set up an
EntityManagerFactoryas well as anEntityManger. -
Create a method
updateNullEmails - In a terminal write a SQL query to display all customers that have null or empty string emails.
- 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.
- In a
main, call this method. -
Check the database to make sure the changes were made.
-
Create a method
addNewAddress - This method should create a new
Addressobject, and set its values to your personal information (street,city,state,postalCode,phone). - Persist your
Addressobject. - Print out the object.
- In a
main, comment out the call toupdateNullEmailsand run this method. -
Check to make sure the new Address was added to the database.
-
Create a method called
deleteAddress - This method should take a address's
idas a parameter. - Write the logic to delete a Address from the database based on its
id. - In a
main, comment out the call toaddNewAddressand run your method, passing in theidvalue of the Address you created previously. - Check the database to make sure the Address was deleted.