Hey all,
I've been working with TDB for a bit now processing data into it, but I've
run into an issue where after adding a named model, I find that the named
model simply disappears, and is inaccessible. Here's some example code:
Model prodModel = null;
dset.begin(ReadWrite.WRITE);
Lock lck = dset.getLock();
try {
lck.enterCriticalSection(Lock.WRITE);
if (dset.containsNamedModel("product_info")) {
prodModel = dset.getNamedModel("product_info");
System.out.println("Using existing model");
} else {
System.out.println("Making new model");
dset.addNamedModel("product_info",
ModelFactory.createDefaultModel());
prodModel = dset.getNamedModel("product_info");
}
dset.commit();
} finally {lck.leaveCriticalSection(); dset.end();}
TDB.sync(dset);
dset.begin(ReadWrite.READ);
Iterator<String> itr = dset.listNames();
while (itr.hasNext()) {
System.out.println(itr.next());
}
dset.end();
In this case dset is a class attribute set by TDBFactory.createDataset
("path/to/dataset/") at construction. Is it possible that this is causing
an issue? If I run this multiple times, containsNamedModel returns false
each time, even though manually inspecting nodes.dat shows it.
I would expect it to print the named graph ("product_info") but instead
nothing is printed. I might be using Jena's TDB interface incorrectly --
it's hard to tell -- but I've been able to do this before with no issue.
I'm using jena-tdb-0.10.1, jena-core-2.10.1, jena-arq-2.10.1.
Thanks,
- Zach Jablons