Updating existing literal value in a graph - Cannot open nested transactions error.

3 views
Skip to first unread message

Tze-John Tang

unread,
May 1, 2014, 3:45:44 PM5/1/14
to sta...@clarkparsia.com
I currently have triples under the graph <urn:x-abbvie:activeDirectory>. Within this graph, I have a triple which I am using to specify the last time this graph was loaded, with a triple like:

<urn:x-abbvie:activeDirectory> <http://schemas.abbvienet.com/ontologies/infrastructure.owl#hasModificationDate> "2014-04-08T09:10:19.331-05:00"^^<http://www.w3.org/2001/XMLSchema#date>


The next time I update data in this graph, I want to update this literal value. So, in my code I was doing something like the following:

 // update the modification date
 
UpdateQuery updateModificationDateQuery = conn.update("delete { ?g ?p ?oldDate } insert { graph ?g { ?g ?p ?newDate }} where { graph ?g { ?g ?p ?oldDate }}");
 updateModificationDateQuery
.parameter("g", adContextUri);
 updateModificationDateQuery
.parameter("p", IInfrastructureSchema.hasModificationDate);
 updateModificationDateQuery
.parameter("newDate", cal.getTime());
 
 updateModificationDateQuery
.execute();

where adContextUri is <urn:x-abbvie:activeDirectory>.

When I execute the update statement, I am getting the error:

com.complexible.stardog.StardogException: com.complexible.stardog.plan.eval.operator.OperatorException: Cannot open nested transactions
at com.complexible.stardog.protocols.client.SPECClientUtil.toStardogException(SPECClientUtil.java:65) ~[client-2.1.1.jar:na]
at com.complexible.stardog.protocols.snarl.client.SNARLUpdateQuery.execute(SNARLUpdateQuery.java:49) ~[client-2.1.1.jar:na]
at com.complexible.stardog.protocols.snarl.client.SNARLUpdateQuery.execute(SNARLUpdateQuery.java:26) ~[client-2.1.1.jar:na]
at abbvie.gprd.emr.db.stardog.AdLoader.load(AdLoader.java:157) [classes/:na]
at abbvie.gprd.emr.db.stardog.AdLoader.main(AdLoader.java:96) [classes/:na]

First off. Is there a better way to replace a single value for a triple?
Secondly, any idea what the error means?

Evren Sirin

unread,
May 1, 2014, 10:13:59 PM5/1/14
to Stardog
Not really. Using the API, the equivalent code would require a get,
remove and add calls:

Statement stmt = aConn.get().predicate(p).context(g).statement();
aConn.remove().statement(stmt);
aConn.add().statement(stmt.getSubject(), p, Values.literal(cal), g);

> Secondly, any idea what the error means?

SPARQL update queries are executed in their own transaction so if you
have an explicit Connection.begin() tat would explain the exception.
Otherwise, we'd need to see the complete code to see what is going on.

As a side note, the delete clause in your SPARQL update query seems to
be missing the graph clause.

Best,
Evren

>
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

TJ Tang

unread,
May 1, 2014, 10:16:17 PM5/1/14
to sta...@clarkparsia.com
Thanks Evren.  Yes, I had a Connection.begin() call earlier. So that would explain it.

-tj


To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

TJ Tang

unread,
May 1, 2014, 10:20:44 PM5/1/14
to stardog
Evren,

Though if I went the API route, then I could keep it as part of a larger transaction, right?

-tj

Evren Sirin

unread,
May 1, 2014, 10:54:54 PM5/1/14
to Stardog
On Thu, May 1, 2014 at 10:20 PM, TJ Tang <ta...@pobox.com> wrote:
> Evren,
>
> Though if I went the API route, then I could keep it as part of a larger
> transaction, right?

Yes, you can combine those with any additional add/remove statements
in the same transaction.

Best,
Evren
Reply all
Reply to author
Forward
0 new messages