Answers inline:

On 14/09/2017 09:54, "George News" <[email protected]> wrote:

    Hi,
    
    Continuing with my issues with transactions, next question ;)
    
    1) If I get a model as a result of a multiunion or a set of entities
    from a read transaction, will I be able to use this model after the
    transaction ends (i.e. in a SPARQL request).
    
    MultiUnion union = new MultiUnion()
    dataset.begin(ReadWrite.READ);
    union.addGraph(dataset.getNamedModel("A").getGraph();
    union.addGraph(dataset.getNamedModel("B").getGraph();
    
    Model m = ModelFactory.createModelForGraph(union);
    dataset.end();
    
    // Execute SELECT SPARQL over m without opening a read transaction
    
    Will it work? What data is included?

This will almost certainly fail since as explained previously the objects you 
are getting are just views over the underlying database rather than copies of 
the data itself. So once you tried to access the data after the transaction has 
 ended those objects will notice that they are no longer in transaction and 
refuse to function.

If you want to use this approach then you could explicitly take a copy of the 
union into a in-memory model. However I am not sure why you want to take this 
approach, read transactions are pretty cheap.
    
    
    2) Suppose I have a webservice exporting read/write functionality from a
    TDB. Every request opens a transaction over the TDB. If the request is
    taking too long the HTTP client closes the connection. What happens with
    the transactions? From my understanding, once the connection from the
    client is closed, all resources for the call are freed at the server and
    then the transactions will be somehow aborted and released. Am I right?

No. The client closing the connection does not immediately notify the server. 
The server will typically only notice that the connection is closed when it 
starts trying to send data back and the writes fail.

Transactions will not be magically aborted without your intervention, you 
should be using standard exception handling i.e. try catch finally blocks to 
ensure that you clean up after yourself.

Rob
    
    
    Thanks a lot for you invaluable help. I feel really sorry for bothering
    so much, but I'm suffering from some stability issues on the developed
    system (mainly memory leaks, etc.) and need to properly understand if
    I'm making things the right way.
    
    Regards,
    
    




Reply via email to