Dave Reynolds commented on JENA-1518:

Confirmed that the issue exists. Amazing it hasn't been noticed before. Thanks 
for the clear report.

The underlying problem seems to be a bug in the way the backward rule system 
does tabling. It looks like results of the goal for the first contains test are 
incorrectly being used to answer the second one, with no results. 

A work around would be to comment out the lines:

{{-> table(rdf:type).}}

in the relevant rules files. You should be able to do that in your application 
by creating your own etc resources folder and including modified versions of 
the rule files. For default rdfs the relevant rule file is 

[It way be a while before I have some free time to look at the underlying issue 
so not assigning issue to me just yet in case anyone else wants to take a look.]

> InfModel does not contain inferred statements when asserted data is accessed 
> first
> ----------------------------------------------------------------------------------
>                 Key: JENA-1518
>                 URL: https://issues.apache.org/jira/browse/JENA-1518
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: Jena 3.6.0
>            Reporter: Martin Ledvinka
>            Priority: Major
> When I create an InfModel (tested on RDFSRuleReasoner, RDFSFBRuleReasoner and 
> OWLMicroReasoner) and I access an asserted statement first, the model does 
> not see inferred statements it previously created. If I access the inferred 
> statements first, everything works fine.
> What's interesting is that when I list all the statements in the model 
> (listStatements().toList()), I can see the relevant statement, but the model 
> ignores it. Demo:
> {{Model model = ModelFactory.createDefaultModel();}}
> {{Resource subject = createResource(SUBJECT);}}
> {{Resource typeOne = createResource(TYPE_ONE);}}
> {{Resource typeTwo = createResource(TYPE_TWO);}}
> {{model.add(typeOne, RDFS.subClassOf, typeTwo);}}
> {{model.add(subject, RDF.type, typeOne);}}
> {{InfModel infModel = 
> ModelFactory.createInfModel(RDFSRuleReasonerFactory.theInstance().create(null),
>  model);}}
> {{assertTrue(infModel.contains(createResource(SUBJECT), RDF.type, typeOne));}}
> {{assertTrue(infModel.contains(createResource(SUBJECT), RDF.type, typeTwo));  
> // This assertion FAILS. But if I switch this line for the one above, it 
> works fine}}
> Also, if I use unbound subject in the contains call on the last line, it 
> returns true, so it seems that it incorrectly matches the 'subject' Resource.
> The same problem can be reproduces on the listStatements method, when first 
> accessing just the asserted statements (using 'typeOne' as object) and then 
> accessing inferred statements (using 'typeTwo' as object).

This message was sent by Atlassian JIRA

Reply via email to