How to build SPARQL queries in java?

后端 未结 8 1753
囚心锁ツ
囚心锁ツ 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();
    

提交回复
热议问题