GitHub user namedgraph created a discussion: Use case for initial bindings
I'm upgrading Jena dependency from 4.7.0 to 6.0.0 and one of the main pain points is the removal of `initialBindings`. I sort of understand the reasoning behind it, but aren't there situations where it _is_ appropriate to use initial bindings? But in 6.0.0 there is no mechanism anymore for doing that? For example, 6.0.0 based code with substitution requires modification of the query algebra ```java Query query = QueryFactory.create(queryText.getString(), baseURI); // Inject BIND(?_this_bind AS ?this) into the WHERE clause. // This keeps ?this as a variable in the CONSTRUCT template (not a written blank node), // so the template picks up the concrete node value — preserving blank node identity. // See: https://github.com/apache/jena/issues/3267 Var bindVar = Var.alloc("_this_bind"); ElementGroup group = new ElementGroup(); group.addElement(query.getQueryPattern()); group.addElement(new ElementBind(Var.alloc(SPIN.THIS_VAR_NAME), new ExprVar(bindVar))); query.setQueryPattern(group); Binding binding = BindingFactory.binding(bindVar, instance.asNode()); try (QueryExecution qex = QueryExecution.create(). query(query). model(instance.getModel()). substitution(binding). build()) { instance.getModel().add(qex.execConstruct()); } ``` where as the old version was simply ```java Query basedQuery = new ParameterizedSparqlString(queryText.getString(), baseURI).asQuery(); QuerySolutionMap bindings = new QuerySolutionMap(); bindings.add(SPIN.THIS_VAR_NAME, instance); // execute the constructor on the target model try (QueryExecution qex = QueryExecution.create(). query(basedQuery). model(instance.getModel()). initialBinding(bindings). build()) { instance.getModel().add(qex.execConstruct()); } ``` I am struggling to understand what exactly has `substitution` over `initialBindings` improved in this situation? GitHub link: https://github.com/apache/jena/discussions/3797 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
