How to build SPARQL queries in java?

后端 未结 8 1584
囚心锁ツ
囚心锁ツ 2021-02-01 10:19

Is there a library, which is able to build SPARQL queries programmatically like the CriteriaBuilder in JPA or to build the queries like with a PreparedStateme

相关标签:
8条回答
  • 2021-02-01 11:13

    I implemented SPARQL Java - a kind of DSL for writing SPARQL queries in Java.

    It solves the problem with IDE's auto formatting of concatenated SPARQL query strings and things like that.

    As for example:

    String shortQuery = Q.prefix("books", "http://example.org/books#")
                .select("?book ?authorName", new where() {
                    {
                        $("?book books:author ?author");
                        $("?author books:authorName ?authorName");
                    }
                }).get();
    
    0 讨论(0)
  • 2021-02-01 11:14

    Jena provides a QueryBuilder in the Extras package.

    https://jena.apache.org/documentation/extras/querybuilder/index.html

    It does what you want.

    0 讨论(0)
提交回复
热议问题