On 28/09/13 23:46, Andreas Grünwald wrote:
Hello,
I am trying to implement proper transaction handling based on the latest
Jena TDB version.

This is how I roughly initialize the model entities (I work with Jena's
OntModel):

class ConnectorWrapper
    public void init() {
       Dataset tdbDataSet = TDBFactory.createDataset(directory);
       model = tdbDataSet.getNamedModel(this.getOntologySchemaIRI());
        this.ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
model);
    }
}

I ran into some problems.

    1. tdbDataSet.abort() is not working for me. As far as I got from the
    documentation, the OwlModel does not support transactions. Did I got that
    correct? Is there any kind of workaround?

Perform the transaction on the tdbDataSet.

Get the model inside the dataset.

    2. How do I properly close/destroy a Jena Dataset? I am running into the
    situation that I have several "Connector" instances (within one Thread),
    which wrap an instance of the Jena Dataset. However, only the first
    initialization succeeds, for the latter I get something like "transaction
    is not active". I also get some errors in the command line "ERROR
    com.hp.hpl.jena.tdb.transaction.BlockMgrJournal - **** Not active: 1"
    although I call "tdbDataSet.close() and tdbDataSet.end()" before calling
    init() again. Is TDBFactory.createDataset(directory) the correct way to
    retrieve a dataset-instance, or should I call another method? Does my
    initialization approach seem ok?

Yes - use TDBFactory.createDataset(directory), or have a single variable for the object and initialize once.

Don't bother closing it - when transactional, close is meaningless (and harmless).

Note that one thread can only have one transaction active.

If that is not working, please could you provide a complete, minimal example as the details matter here.

        Andy


Thank you very much and best regards,
Andreas


Reply via email to