// When copying statements between OWLIM instances like this: RepositoryResult stats = repositoryConnection1.getStatements(null, null, null, false); while (stats.hasNext()) { // Call purify on the statement to recreate it fully and remove any dependencies on // the caching in the first OWLIM instance repositoryConnection2.add(purify(stats.next(), repositoryConnection)); } stats.close(); // ============================ public static Statement purify(Statement st, RepositoryConnection c) { ValueFactory f = c.getValueFactory(); if (st.getContext() == null) { return f.createStatement( purify(st.getSubject(), c), purify(st.getPredicate(), c), purify(st.getObject(), c)); } else { return f.createStatement(purify(st.getSubject(), c), purify(st.getPredicate(), c), purify(st.getObject(), c), purify(st.getContext(), c)); } } public static Resource purify(Resource res, RepositoryConnection c) { if (res instanceof URI) { return purify((URI) res, c); } else { return purify((BNode) res, c); } } public static Value purify(Value val, RepositoryConnection c) { if (val instanceof Resource) { return purify((Resource) val, c); } else { return purify((Literal) val, c); } } public static URI purify(URI uri, RepositoryConnection c) { ValueFactory f = c.getValueFactory(); return f.createURI(uri.toString()); } public static BNode purify(BNode bnode, RepositoryConnection c) { ValueFactory f = c.getValueFactory(); return f.createBNode(bnode.toString()); } public static Literal purify(Literal literal, RepositoryConnection c) { ValueFactory f = c.getValueFactory(); if (literal.getLanguage() != null) { return f.createLiteral(literal.getLabel(), literal.getLanguage()); } else if (literal.getDatatype() != null) { return f.createLiteral(literal.getLabel(), literal.getDatatype()); } else { return f.createLiteral(literal.getLabel()); } }