I've been working with Jena for a while, but limited mainly to the model layer.
Within the past week, I've been trying to take my knowledge of the API to a
deeper level. I'm interested in the idea of being able to use named graphs
(perhaps as provenance for a given data source), and learning about Quads as
well.
I've been spending time on the Graph layer, and have a question given the code
below (ARQ 2.8.8, Jena 2.6.4, TDB 0.8.10):
DatasetGraph dsg = TDBFactory.createDatasetGraph(“/path/”);
Node gn = Node.createURI(namespace.concat("itp.graph"));
Graph g = dsg.getGraph(gn);
Node s = Node.createURI(namespace.concat("joe"));
Node p = Node.createURI(namespace.concat("seenAt"));
Node o = Node.createURI(namespace.concat("wendys"));
Triple t = new Triple(s, p, o);
g.add(t);
dsg.addGraph(gn, g);
System.out.println(dsg);
The last line prints out what I expect to see:
(dataset
(graph)
(graph <http://mynamespace.com#itp.graph>
(triple <http://mynamespace.com#joe> <http://mynamespace.com#seenAt>
<http://mynamespace.com#wendys>)
))
If I use this code on a subsequent call:
DatasetGraph dsg = TDBFactory.createDatasetGraph(“/path/”);
System.out.println(dsg);
I get nothing:
(dataset
(graph)
)
The triple I created in the first call doesn't appear to be persisted. Is that
expected behavior at the graph layer (which I understand has pretty minimal
functionality), or have I missed something? I was wondering if someone could
shed more light on this. Thanks!