Hi Luca,
Thanks for the reply. I'm using the graph API.
I'm using the
graph.command(new OCommandSQL(query));
method.
I hope this is what you are asking.
For now, I've made a workaround something like:
Integer x = vertex.getProperty("balance");
vertex.setProperty("balance" , x + 10);
vertex.setProperty("IsProcessed", true);
graph.commit();
I hope that if another thread is changing this at the same time (between
reading the "balance" and commiting) a ONeedRetryException exception will
the thrown.
Kind regards,
Manuel
On Friday, January 30, 2015 at 6:29:02 PM UTC, Lvc@ wrote:
>
> Hi Manuel,
> How did you execute this command? What Driver/API?
>
> Lvc@
>
>
> On 30 January 2015 at 15:29, Manuel Coutinho <[email protected]
> <javascript:>> wrote:
>
>> Just some more info:
>>
>> I'm updating a balance (decreasing the value of the balance) and need to
>> mark the movement as "processed"
>>
>> I tried this SQL command: " UPDATE #20:11 INCREMENT Balance = '-1000' ;
>> UPDATE #21:7 SET IsProcessed = 'true' "
>>
>> and the Balance might give an error since the minimum value is 0.
>>
>> The problem occurs when the Balance goes below 0, the first update fails
>> (as expected) but the second update is performed!
>> I guessed performing everything on the same SQL command would make it on
>> the same transaction but it doesn't.
>>
>> How can I perform these operations on the same transaction?
>>
>> Thank you and kind regards,
>> Manuel Coutinho
>>
>>
>> On Saturday, June 2, 2012 at 6:40:29 PM UTC+1, Salvatore Piccione wrote:
>>
>>> Hello,
>>>
>>> I've defined some tests on transactions (both Blueprints and Orient
>>> native ones) in order to verify if SQL statements are aware of the
>>> transaction context in which they are executed.
>>> You can find a test case about the execution of SQL INSERTs into an
>>> index and a class inside a transaction at https://gist.github.com/
>>> 2859180.
>>> It seems that such SQL statements are not aware of the transaction scope
>>> defined in the code. In particular I found the following issues:
>>>
>>> - the graph element created through a SQL INSERT is not deleted when
>>> the transaction is rolled back
>>> - the SQL INSERT into an index doesn't work if the graph element to
>>> be added has been defined in a transaction by using Java API (it's got a
>>> temporary RID). In particular I get [1] if the vertex has been defined
>>> through Blueprints API while I get [2] if the vertex has been defined
>>> through native API. Additionally, I've discovered that:
>>> - if you use the Blueprints API to define the vertex, you get a
>>> temporary RID with the right cluster id (6 for Vertex and 7 for Edge)
>>> - if you use native graph API to define the vertex, you get a
>>> temporary RID with a temporary (i.e. negative) cluster id. This
>>> happens
>>> even passing the name of the class in the method
>>> OGraphDatabase.createVertex(). Any idea about this?
>>>
>>> I'd like to know if the SQL statement's unawareness of the transaction
>>> scope is a known issue or I did something wrong in mt code. At the moment,
>>> I'm forced to use only Java API to change (insert, modify and delete) my
>>> data inside a transaction to make transaction working fine.
>>>
>>> TIA,
>>>
>>> Salvatore
>>>
>>> [1] Stack trace got using Blueprints API
>>> com.orientechnologies.orient.core.exception.OCommandExecutionException:
>>> Error on execution of command: OCommandSQL [text=INSERT INTO
>>> index:aManualIdx(key,rid) VALUES (52,#6:-2)]
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at java.lang.reflect.Constructor.newInstance(Unknown Source)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.createException(OChannelBinary.java:409)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.handleStatus(OChannelBinary.java:364)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:60)
>>> at com.orientechnologies.orient.client.remote.OStorageRemote.
>>> beginResponse(OStorageRemote.java:1492)
>>> at com.orientechnologies.orient.client.remote.OStorageRemote.
>>> command(OStorageRemote.java:703)
>>> at com.orientechnologies.orient.client.remote.
>>> OStorageRemoteThread.command(OStorageRemoteThread.java:191)
>>> at com.orientechnologies.orient.core.command.
>>> OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:60)
>>> at org.example.orientdb.TestIndexUsageInTransaction.
>>> testBlueprintsAPI(TestIndexUsageInTransaction.java:117)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
>>> FrameworkMethod.java:45)
>>> at org.junit.internal.runners.model.ReflectiveCallable.run(
>>> ReflectiveCallable.java:15)
>>> at org.junit.runners.model.FrameworkMethod.invokeExplosively(
>>> FrameworkMethod.java:42)
>>> at org.junit.internal.runners.statements.InvokeMethod.
>>> evaluate(InvokeMethod.java:20)
>>> at org.junit.internal.runners.statements.RunBefores.
>>> evaluate(RunBefores.java:28)
>>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>>> BlockJUnit4ClassRunner.java:68)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>>> BlockJUnit4ClassRunner.java:47)
>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>>> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
>>> JUnit4TestReference.java:50)
>>> at org.eclipse.jdt.internal.junit.runner.TestExecution.
>>> run(TestExecution.java:38)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> runTests(RemoteTestRunner.java:467)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> runTests(RemoteTestRunner.java:683)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> run(RemoteTestRunner.java:390)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> main(RemoteTestRunner.java:197)
>>> Caused by: java.lang.NullPointerException
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at java.lang.reflect.Constructor.newInstance(Unknown Source)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.createException(OChannelBinary.java:411)
>>> ... 32 more
>>>
>>> [2] Stack trace got using native API
>>> com.orientechnologies.orient.core.exception.OCommandExecutionException:
>>> Error on execution of command: OCommandSQL [text=INSERT INTO
>>> index:aManualIdx(key,rid) VALUES (52,#-1:-1)]
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at java.lang.reflect.Constructor.newInstance(Unknown Source)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.createException(OChannelBinary.java:409)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.handleStatus(OChannelBinary.java:364)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:60)
>>> at com.orientechnologies.orient.client.remote.OStorageRemote.
>>> beginResponse(OStorageRemote.java:1492)
>>> at com.orientechnologies.orient.client.remote.OStorageRemote.
>>> command(OStorageRemote.java:703)
>>> at com.orientechnologies.orient.client.remote.
>>> OStorageRemoteThread.command(OStorageRemoteThread.java:191)
>>> at com.orientechnologies.orient.core.command.
>>> OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:60)
>>> at org.example.orientdb.TestIndexUsageInTransaction.testNativeAPI(
>>> TestIndexUsageInTransaction.java:164)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
>>> FrameworkMethod.java:45)
>>> at org.junit.internal.runners.model.ReflectiveCallable.run(
>>> ReflectiveCallable.java:15)
>>> at org.junit.runners.model.FrameworkMethod.invokeExplosively(
>>> FrameworkMethod.java:42)
>>> at org.junit.internal.runners.statements.InvokeMethod.
>>> evaluate(InvokeMethod.java:20)
>>> at org.junit.internal.runners.statements.RunBefores.
>>> evaluate(RunBefores.java:28)
>>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>>> BlockJUnit4ClassRunner.java:68)
>>> at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>>> BlockJUnit4ClassRunner.java:47)
>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>>> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(
>>> JUnit4TestReference.java:50)
>>> at org.eclipse.jdt.internal.junit.runner.TestExecution.
>>> run(TestExecution.java:38)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> runTests(RemoteTestRunner.java:467)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> runTests(RemoteTestRunner.java:683)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> run(RemoteTestRunner.java:390)
>>> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.
>>> main(RemoteTestRunner.java:197)
>>> Caused by: java.lang.ClassCastException
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
>>> Source)
>>> at java.lang.reflect.Constructor.newInstance(Unknown Source)
>>> at com.orientechnologies.orient.enterprise.channel.binary.
>>> OChannelBinary.createException(OChannelBinary.java:411)
>>> ... 32 more
>>>
>>>
>>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "OrientDB" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.