public void addType() { final LockableMGraph dataGraph = getDataGraph(); Lock l = dataGraph.getLock().writeLock(); l.lock(); try { final Iterator<Triple> triples = dataGraph.filter(null, ADDRESSES.name, null); final Collection<NonLiteral> addresses = new HashSet<NonLiteral>(); while (triples.hasNext()) { NonLiteral address = triples.next().getSubject(); addresses.add(address); } for (NonLiteral address : addresses) { dataGraph.add(new TripleImpl(address, RDF.type, ADDRESSES.Address)); } } finally { l.unlock(); } }