arianpotter opened a new issue, #3223:
URL: https://github.com/apache/jena/issues/3223
### Version
5.3.0
### Question
Dear Community Members,
As a part of the project that I am working on now, I have to create dynamic
SPARQL queries. To this end, I am using Jena's ARQ library QueryBuilder.
The issue that I am facing now is that I need to be able to nest
WhereBuilders into each other with FILTER EXISTS and I have a function like
below that adds a WhereBuilder to another as FILTER EXISTS:
` private void addFilterExists(WhereBuilder outerBuilder, WhereBuilder
innerBuilder) {
Element innerElement = innerBuilder.build().getQueryPattern();
ElementGroup group = new ElementGroup();
group.addElement(innerElement);
Expr notExistsExpr = new E_Exists(group);
outerBuilder.addFilter(notExistsExpr);
}`
This works fine if I use it once. But if I have to nest the query again with
this function into another WhereBuilder, and there is a BIND clause somewhere
in the inner query, I get the error "Attempt to assign an expression again".
I can not remove BIND clauses as they are getting added dynamically and are
important. On the other hand, I believe the issue arises from the fact that I
have to build the inner query, and when I put this built query into another
whereclause and then this whereclause gets built as the inner query of another
clause I get this Error while doing: Expr notExistsExpr = new E_Exists(group);
Also, not building the inner query is not an option because trying to nest
these without building(with WhereHandler) leads to a NullPointer exception
Error.
I really appreciate any help or workaround if it is possible, as I am
getting frustrated with this issue and have not found a solution so far.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]