On 04/02/13 13:17, A. Anil SINACI wrote:
Hi all,

Having retrieved the default model through Model m =
dataset.getDefaultModel(), I can see that any change on m is persistent
after a TDB.sync in non-transactional or after a commit in transactional
model.

While using named models, after adding a model to the dataset through
dataset.addNamedModel(uri, model), then changes (i.e. adding a new
triple to the model) on this added named model are not persistent on TDB
neither in non-transactional nor in transactional mode. I need to
explicitly call dataset.replaceModel to make the changes persistent.

What I need is to have the same behavior of default model for my named
models added to the dataset. Is the "replaceModel" the only way to
achieve this? Or, should I only work on the default model?

Best,
Anil.

dataset.addNamedModel(uri, model) adds the model at that point in time, to the dataset. If it's an in-memeory model, it remains an in-memory model - the contests are copied into the database. Models can't change their storage technology in their life time.

If you want an updateable view of the model in the dataset use:

    Dataset ds = TDBFactory.createDataset("DB") ;

    ds.begin(ReadWrite.WRITE) ;
    try {
        Model m = ds.getNamedModel("http://example/g";) ;
        FileManager.get().readModel(m, "D.ttl") ;
        // Jena 2.10.0 ---> preferred style
        // RDFDataMgr.read(m, "D.ttl") ;
        ds.commit() ;
    } finally { ds.end() ; }


        Andy

Reply via email to