Created
May 7, 2010 15:33
-
-
Save kendall/393588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let's edit our book...maybe we changed the title and published as a PDF | |
aNewBook.setTitle("Return of the Empire"); | |
// create a new manifestation | |
Manifestation aPDFManifestation = new Manifestation(); | |
aPDFManifestation.setIssued(new Date()); | |
// set the dc:type attribute | |
aPDFManifestation.setType(URI.create("http://purl.oreilly.com/product-types/PDF")); | |
aNewBook.setEmbodiments(Arrays.asList(aPDFManifestation)); | |
// now save our edits | |
aManager.merge(aNewBook); | |
// print the new information we just saved | |
System.err.println(aNewBook.getTitle()); | |
System.err.println(aNewBook.getEmbodiments()); | |
// and importantly, verify that the new manifestation was also saved due to the cascaded merge operation | |
// specified in the Book class via the @OneToMany annotation | |
// true! | |
System.err.println(aManager.contains(aPDFManifestation)); | |
// the copy of the book contains the old information | |
System.err.println(aNewBookCopy.getTitle()); | |
System.err.println(aNewBookCopy.getEmbodiments()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment