Skip to content

Instantly share code, notes, and snippets.

@kendall
Created May 7, 2010 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kendall/393588 to your computer and use it in GitHub Desktop.
Save kendall/393588 to your computer and use it in GitHub Desktop.
// 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