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
{ | |
"service-discovery" : { | |
"response-mimetype" : [ "text/json", "application/rdf+xml", "application/x-turtle", "application/x-ntriples" ], | |
"endpoint" : { | |
"http-methods" : [ "GET" ], | |
"url" : "http://foo:8080/" | |
} | |
}, | |
"knowledge-bases" : [ { | |
"name" : "wine", |
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)); |
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
Book aBook = aManager.find(Book.class, URI.create("urn:x-domain:oreilly.com:product:9780596514129.IP")); | |
// prints: Switching to the Mac: The Missing Manual, Leopard Edition | |
System.err.println(aBook.getTitle()); | |
// prints: O'Reilly Media / Pogue Press | |
System.err.println(aBook.getPublisher()); |
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
EntityManager aManager = Persistence.createEntityManagerFactory("oreilly") | |
.createEntityManager(); |
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
Empire.init(new OpenRdfEmpireModule()); |
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
@OneToMany(fetch = FetchType.LAZY, | |
cascade = {CascadeType.PERSIST, CascadeType.MERGE}) | |
private Collection<Manifestation> mEmbodiments = new HashSet<Manifestation>(); |
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
private String title; | |
private String publisher; | |
private Date issued; |
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
// ... annotations ... | |
public class Book implements SupportsRdfId |
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
@Entity | |
public class Book |
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
// now we can delete our new book | |
aManager.remove(aNewBook); | |
// false! | |
System.err.println(aManager.contains(aNewBook)); | |
// but the new manifestation still exists, since we did not specify that deletes should cascade... | |
// true! | |
System.err.println(aManager.contains(aPDFManifestation)); |