On 20/05/14 08:15, Joakim Soderberg wrote:
Hi,
I create a dataset with a unnamed default model and a named model
mDataset = TDBFactory.createDataset(tdbDirectory);
mDefaultModel = mDataset.getDefaultModel();
mDefaultModel = FileManager.get().loadModel(coreOntologyFile);
Model rtmodel = FileManager.get().loadModel("ontology/data1221.rdf");
if (mDataset.containsNamedModel("r1221"))
{
mDataset.getNamedModel("r1221");
} else {
mDataset.getDataSet().addNamedModel("rt1221", rtmodel);
}
From what I read, passing a dataset and not specifying "FROM NAMED" in the
sparql query, should query both the unnamed model and named model, but it
only queries the default data set, e.g.
QueryExecution qe1 = QueryExecutionFactory.create( "SELECT * WHERE { ?s ?p
?o }", mDataset );
only returns data from the defaultmodel, unless if I explicitly pass the
named model
QueryExecution qe1 = QueryExecutionFactory.create( "SELECT * WHERE { ?s ?p
?o }", mDataset.getNamedModel("r1221") );
then I get triples from the named model. Adding FROM NAMED <e1221>
"SELECT * FROM NAMED <r1221> WHERE { ?s ?p ?o> }", mDataset
Does not help. Has anyone had the same problem?
try this query:
SELECT * {
{ ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } }
}
"SELECT * WHERE { ?s ?p ?o }" only accesses the default graph. You need
GRAPH to get to the named graphs.
You can have many named graphs and make the default graph of the query
by the union of all named graphs (see documentation [*]), but the stored
default graph isn't then visible in { ?s ?p ?o }
Andy
[*] http://jena.apache.org/documentation/tdb/datasets.html
best
J