Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7700755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:49:17+00:00 2026-05-31T22:49:17+00:00

Is it possible to query data from a Model without writing sqarql-queries? Adding properties

  • 0

Is it possible to query data from a Model without writing sqarql-queries? Adding properties to resources or resources to models can be done easily, but I haven’t found out yet, if there is a more efficient way to query data from a Model than using code the one below:

    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(); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:49:19+00:00Added an answer on May 31, 2026 at 10:49 pm

    You can use the list* methods available on a Jena Model:
    http://incubator.apache.org/jena/documentation/javadoc/jena/com/hp/hpl/jena/rdf/model/Model.html

    For example, model.listStatements() or model.listStatements ((Resource)null, RDF.type, (RDFNode)null), etc.

    You can find an example of model.listStatements() here:
    https://github.com/castagna/jena-examples/blob/995d7acf8fcb3f9a8f7264dfd0902cdddfc00279/src/main/java/org/apache/jena/examples/ExampleAPI_01.java

    See also the section “Querying a Model” in the Jena tutorial on the Jena website:
    http://incubator.apache.org/jena/tutorials/rdf_api.html#ch-Querying%20a%20Model

    One last comment, in terms of efficiency you should not see much difference, indeed I do not think there is a difference. For every list* methods in Model you can write a very simple SPARQL query and compare performances yourself. If what you want is available as a method of a Model then use it, but you’ll soon find that when you want to do more, SPARQL queries can be more concise and allows you to get back just exactly what you need with less code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code I'm writing copies data from one table to another. It is possible
I have the following sql query for transforming data but is it possible to
Is is possible to query the current browser from within an applet? I would
Hi all is it possible to rewrite query: select userid from User where userid
I can use the following syntax in a Jet (mdb) query to select data
I am trying to paginate some data from a model called D filtering results
I'm looking for the best possible way of sharing model data between two MVC
I'm wondering if it's possible to move all data from one column in table
I got this Doctrine query: select upper(substring(e.name, 1, 1)) first_letter from Application\Models\Exercise e group
Is it possible to query certificate store on windows server 2008 using .net platform?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.