Skip to content
Martin Ledvinka edited this page Aug 23, 2023 · 4 revisions

JOPA

JOPA is a JPA-like persistence framework for RDF/OWL.

Its main features are:

  • Object-ontological mapping (OOM) based on integrity constraints,
  • Explicit access to inferred knowledge,
  • Access to unmapped properties and individual's types,
  • Transactions,
  • Separate storage access layer - Jena, OWLAPI, RDF4J (Sesame) drivers are available.

Javadoc is available at the KBSS portal.

Some common issues are discussed in the FAQ section.

Persistence Setup

Initializing persistence is done by calling the Persistence.createEntityManagerFactory() method with appropriate properties. There are several required parameters:

Parameter Explanation
cz.cvut.jopa.scanPackage The package(s) in which entity declarations reside. Use , to separate multiple packages or leave the property empty to make JOPA use the whole classpath.
cz.cvut.kbss.jopa.model.PersistenceProvider This is mostly a legacy of JOPA's resemblance to JPA and specifies a persistence provider implementation to use. Use cz.cvut.kbss.jopa.model.JOPAPersistenceProvider for JOPA.
cz.cvut.jopa.dataSource.class DataSource implementation to use. This is how the OntoDriver implementation is specified. Each of the drivers has a dedicated DataSource implementation class whose fully qualified canonical name should be used as this property's value.
cz.cvut.jopa.ontology.physicalURI Physical URI of the storage. This can be a remote RDF4J repository URL, a folder for Jena TDB or an OWL file location. A physical URI is required also for in-memory storage. However, its value is not important in this case.

JOPA no longer requires a logical ontology IRI, since a) RDF4J and Jena don't need it for RDF access and b) OWLAPI also supports anonymous ontologies, so it is not strictly speaking required to specify a logical IRI.

Other properties apply to the individual OntoDriver implementations and info about them can be found on a dedicated Wiki page.

The following is a bare-bones example of starting up a JOPA persistence unit:

final EntityManagerFactory emf = Persistence.createEntityManagerFactory("test-pu", Map.of(
    "cz.cvut.jopa.scanPackage", "org.example.jopa.model",
    "cz.cvut.kbss.jopa.model.PersistenceProvider", "cz.cvut.kbss.jopa.model.JOPAPersistenceProvider",
    "cz.cvut.jopa.dataSource.class", "cz.cvut.kbss.ontodriver.rdf4j.Rdf4jDataSource",
    "cz.cvut.jopa.ontology.physicalURI", "http://localhost:18080/rdf4j-server/repositories/test"));