java - Jena TDB: Querying a named model -


i'm trying query jena named model stored (precisely dbpedia tbox). storage done in following way

dataset dataset = tdbfactory.createdataset(path); dataset.begin(readwrite.write); model model = dataset.getnamedmodel(graph); ontmodel ontmodel = modelfactory.createontologymodel(); model.add(filemanager.get().readmodel(ontmodel, dbpedia)); model.commit(); model.close(); dataset.commit(); dataset.end(); dataset.close(); 

path contains path tdb, graph contains name of named model , dbpedia contains path owl file. until point seems fine:

when later want query model, following:

dataset dataset = tdbfactory.createdataset(path); dataset.begin(readwrite.read); list<string> out = lists.newarraylist(); try(queryexecution qexec = queryexecutionfactory.create("select * { graph ?g {?s ?p ?o}}",  dataset.getnamedmodel(graph))) {     resultset rs = qexec.execselect();     resultsetformatter.out(rs);     rs.foreachremaining(triple -> out.add(triple.tostring())); } catch (exception e) {     e.printstacktrace(); } dataset.close(); 

the output resultsetformatter.out(rs) empty, follows:

----------------- | s | p | o | g | ================= ----------------- 

however, in debugger mode, can see property dataset dataset.getnamedmodel(graph) has data there.

enter image description here

i assume problem query, seems fine me. missing something?

thanks!

queryexecutionfactory.create("select * { graph ?g {?s ?p ?o}}", dataset.getnamedmodel(graph)))

that asks query on graph in isolation. graphs not have names - slot in dataset has name.

querying model querying default graph of dataset (that gets created internally make query execution).

try queryexecutionfactory.create("select * { graph ?g {?s ?p ?o}}", dataset)


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -