Labs
-
Create a class
RelationshipCRUDClientin thecom.example.jpavideostore.clientpackage. -
Write a method
public void addNewActorToFilm()that - Creates a new Actor object with
firstNameandlastNamevalues. - Sets up a relationship such that the new Actor is in the movie LADYBUGS ARMAGEDDON (film with id 507).
-
Persists the actor to the database.
-
Create a
mainmethod in yourRelationshipCRUDClientclass. Have it invoke youraddNewActorToFilmmethod. -
Check your SQL database to see if the new Actor was created, and that the appropriate relationship was added to the
film_actortable. -
Write a method
public void newCustomerAndAddress()that - Creates a new Address with the following values set:
streetcitystatephone
- Creates a new Customer object with the following values set:
firstNamelastNamestore(use the store with id 1)emailcreatedAt(usenew Date()to get todays date)address(use the address you just created)
- Add a
CascadeType.Persistto the@OneToOneannotation on the Customer'saddressfield. -
Persists the Customer to the database.
-
Comment out the call to
addNewActorToFilmand invoke yournewCustomerAndAddressmethod inRelationshipCRUDClient'smainmethod. - Check your SQL database to see if the new Address and Customer objects were created.