Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.