क्या sqarql-query लिखने के बिना Model
से डेटा पूछना संभव है? मॉडल के लिए संसाधनों या संसाधनों के गुण जोड़ना आसानी से किया जा सकता है, लेकिन मैं बाहर नहीं मिला है फिर भी, अगर वहाँ नीचे एक कोड का उपयोग करने से एक Model
से डेटा क्वेरी करने के लिए एक अधिक कुशल तरीका है:जेना: मॉडल से डेटा कैसे पूछें?
String sparql = "SELECT ?thing ?str WHERE { " +
"?thing a <" + THING + "> . " +
"?thing <" + HAS_STRING + "> ?str . " +
"FILTER (?str = \"" + s + "\") . }";
Query qry = QueryFactory.create(sparql);
QueryExecution qe = QueryExecutionFactory.create(qry, getModel());
ResultSet rs = qe.execSelect();
while(rs.hasNext())
{
QuerySolution sol = rs.nextSolution();
RDFNode str = sol.get("str");
RDFNode thing = sol.get("thing");
...
}
qe.close();