Question: I've been looking but can't find an answer to this so I'm hoping someone can help. I have two tables

Table 1 (audited items)

```
audit_session_id    asset_number 
Audit1              1      
Audit1              2       
Audit2              3       

```

Table 2 (asset)

```
asset_number location<br>
1            15
2            10
3            15

```

What I want is a table of assets that appear in Table 2 but not in Table 1 for a given location and audit\_session\_id. What I have is:   

```
SELECT a.asset_number 
FROM auditeditems ai 
RIGHT JOIN asset a 
  on ai.asset_number = a.asset_number 
WHERE ai.asset_number IS NULL 
AND a.location_id=15;

```

However I can't filter on audit\_session\_id as it is NULL. So I get the result:

1,3 when it should just be 1. (assuming I was looking at the audit1 session)

I keep thinking this should be straight forward but can't see where I'm going wrong. Thanks in Advance

Answer: 
Unfortunately, there is little the SO community can help with if you don't provide even a log trace or a code snippet (doesn't have to be directly executable, but an MWE helps).

First, you should use [DCMI `hasPart` term](http://dublincore.org/documents/dcmi-terms/#terms-hasPart) for representing `hasPart` relationship.

I recommend that you [check all Model statements](https://jena.apache.org/tutorials/rdf_api.html#ch-Statements) before you save it. After that [make sure you are in a Transaction](https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/Dataset.html#isInTransaction--).

If this helps you, please update the question properly so that this can become an answer to a *real question*, not just a vague description of the problem.
It proved that extracting the resource from the `Dataset` and using that reference instead (the code was holding a reference to the instance created in the first place) adding the property (hasPart) proved to work as expected. No error reported by the logging framework, and the hasPart-property is in place. 

The resources affected resides in the default graph of the `Dataset`. 

*Observation*: using `getResource(uri)` does return the resource, but it seems to be a copy (?) as the instance id:s differ. 

Thanks berezovskiy for helping out on the details of this.