[
https://issues.apache.org/jira/browse/JENA-1135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Todd Schiller updated JENA-1135:
--------------------------------
Description:
I'm trying to query an in-memory named graph with SPARQL. Any ideas why the
following would be returning no results?
I'm guessing that the "<urn:graph>" is not being resolved as I would expect?
{code:title=GraphTest.java|borderStyle=solid}
import org.apache.jena.query.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.vocabulary.RDFS;
public class GraphTest {
public static void main(String [] args) {
Dataset data = DatasetFactory.create();
Model model = ModelFactory.createDefaultModel();
model.getResource("urn:foo").addLiteral(RDFS.label, "foobar");
data.addNamedModel("urn:graph", model);
String sparql = "SELECT ?s ?p ?o FROM <urn:graph> WHERE { ?s ?p ?o }";
ResultSet results = QueryExecutionFactory.create(sparql,
data).execSelect();
int cnt = 0;
while (results.hasNext()) {
cnt++;
results.next();
}
// should both print 1
System.out.println("# results: " + cnt); // prints 0
System.out.println("Model size: " +
data.getNamedModel("urn:graph").size()); // prints 1
}
}
{code}
was:
I'm trying to query an in-memory named graph with SPARQL. Any ideas why the
following would be returning no results?
{code:title=GraphTest.java|borderStyle=solid}
import org.apache.jena.query.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.vocabulary.RDFS;
public class GraphTest {
public static void main(String [] args) {
Dataset data = DatasetFactory.create();
Model model = ModelFactory.createDefaultModel();
model.getResource("urn:foo").addLiteral(RDFS.label, "foobar");
data.addNamedModel("urn:graph", model);
String sparql = "SELECT ?s ?p ?o FROM <urn:graph> WHERE { ?s ?p ?o }";
ResultSet results = QueryExecutionFactory.create(sparql,
data).execSelect();
int cnt = 0;
while (results.hasNext()) {
cnt++;
results.next();
}
// should both print 1
System.out.println("# results: " + cnt); // prints 0
System.out.println("Model size: " +
data.getNamedModel("urn:graph").size()); // prints 1
}
}
{code}
> Cannot query named graph in in-memory dataset
> ---------------------------------------------
>
> Key: JENA-1135
> URL: https://issues.apache.org/jira/browse/JENA-1135
> Project: Apache Jena
> Issue Type: Bug
> Components: ARQ, Jena
> Affects Versions: Jena 3.0.1
> Reporter: Todd Schiller
>
> I'm trying to query an in-memory named graph with SPARQL. Any ideas why the
> following would be returning no results?
> I'm guessing that the "<urn:graph>" is not being resolved as I would expect?
> {code:title=GraphTest.java|borderStyle=solid}
> import org.apache.jena.query.*;
> import org.apache.jena.rdf.model.*;
> import org.apache.jena.vocabulary.RDFS;
> public class GraphTest {
> public static void main(String [] args) {
> Dataset data = DatasetFactory.create();
> Model model = ModelFactory.createDefaultModel();
> model.getResource("urn:foo").addLiteral(RDFS.label, "foobar");
> data.addNamedModel("urn:graph", model);
> String sparql = "SELECT ?s ?p ?o FROM <urn:graph> WHERE { ?s ?p ?o }";
> ResultSet results = QueryExecutionFactory.create(sparql,
> data).execSelect();
> int cnt = 0;
> while (results.hasNext()) {
> cnt++;
> results.next();
> }
>
> // should both print 1
> System.out.println("# results: " + cnt); // prints 0
> System.out.println("Model size: " +
> data.getNamedModel("urn:graph").size()); // prints 1
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)