Hi Nick;
Did you find any solution for your problem also I have same problem. I try 
to update graphdb and documentDb but I fail. OrientDb does not support 
nested transactions but there should be a way to update document and graph 
in same atomic operation. If there is no wat how we say OrientDb has ACID.
http://www.orientechnologies.com/docs/last/orientdb.wiki/Document-Database.html
"Transactions are managed at the database level. Nested transactions are 
currently not supported. A database instance can only have one transaction 
running."
Best regards.

13 Şubat 2015 Cuma 22:15:08 UTC+2 tarihinde Nick Pratt yazdı:
>
> Are nested transactions supposed to work in 2.0.2?
>
> We've read the docs on the wiki, but its not clear to us what is supposed 
> to work and how.
>
> Here's a junit test case:
>
> package com.vertex.orientdb;
>
> import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
> import com.orientechnologies.orient.core.record.impl.ODocument;
> import com.orientechnologies.orient.core.sql.OCommandSQL;
> import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
> import org.junit.*;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> public class UpgraderTest
> {
>    private static final Logger log = LoggerFactory.getLogger( 
> UpgraderTest.class );
>    private ODatabaseDocumentTx db;
>    private OrientGraphFactory factory;
>
>    @Before
>    public void setUp() throws Exception
>    {
>       factory = new OrientGraphFactory( "memory:test", "admin", "admin" );
>       db = factory.getDatabase();
>    }
>
>    @After
>    public void tearDown() throws Exception
>    {
>       factory.close();
>    }
>
>    @Test
>    public void testTransactions() throws Exception
>    {
>       db.command( new OCommandSQL( "CREATE CLASS person" ) ).execute();
>       db.command( new OCommandSQL( "CREATE PROPERTY person.name string" ) 
> ).execute();
>
>       db.begin();
>       try
>       {
>          transactionalMethod1();
>          log.info( "5a - count: {}", db.countClass( "Person" ) );
>       }
>       catch( Exception e )
>       {
>          log.info( "5b - count: {}", db.countClass( "Person" ) );
>          db.rollback();
>          log.info( "5c - count: {}", db.countClass( "Person" ) );
>       }
>    }
>
>    public void transactionalMethod1()
>    {
>       log.info( "1 - count: {}", db.countClass( "Person" ) );
>       db.begin();
>       try
>       {
>          new ODocument( "person" ).field( "name", "Test1" ).save();
>          log.info( "2 - count: {}", db.countClass( "Person" ) );
>
>          transactionalMethod2();
>          db.commit();
>       }
>       catch( Exception e )
>       {
>          log.error( e.getMessage(), e );
>          log.info( "Rolling back in method1()" );
>          db.rollback();
>          throw e;
>       }
>    }
>
>    public void transactionalMethod2()
>    {
>       db.begin();
>       try
>       {
>          log.info( "3 - count: {}", db.countClass( "Person" ) );
>
>          new ODocument( "Person" ).field( "Name", "Test2" ).save();
>
>          log.info( "4 - count: {}", db.countClass( "Person" ) );
>          throw new RuntimeException( "" );
>       }
>       catch( Exception e )
>       {
>          db.rollback();
>          throw e;
>       }
>    }
> }
>
>
> Every log line prints out the count as 0 - none of the changes seem to be 
> visible in the callstack:
>
>
> 2015-02-13 20:02:57,297 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 1 - count: 0
> 2015-02-13 20:02:57,306 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 2 - count: 0
> 2015-02-13 20:02:57,307 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 3 - count: 0
> 2015-02-13 20:02:57,307 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 4 - count: 0
> 2015-02-13 20:02:57,308 ERROR [main] <> com.vertex.orientdb.UpgraderTest - 
> java.lang.RuntimeException: 
> at 
> com.vertex.orientdb.UpgraderTest.transactionalMethod2(UpgraderTest.java:85)
> at 
> com.vertex.orientdb.UpgraderTest.transactionalMethod1(UpgraderTest.java:63)
> at com.vertex.orientdb.UpgraderTest.testTransactions(UpgraderTest.java:43)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
> at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
> 2015-02-13 20:02:57,314 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> Rolling back in method1()
> 2015-02-13 20:02:57,314 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 5b - count: 0
> 2015-02-13 20:02:57,315 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 5c - count: 0
>
> Secondly, we're also seeing unexpected results related to rollback and the 
> timing of the rollback - rollbacks in nested transactions (which have 
> joined the parent/outer transaction) don't seem to be rolling back until 
> later than we expected (if at all)
>
> Also, try this test case:
>
> @Test
> public void testTransactionalMethod5()
> {
>    db.begin();
>    log.info( "0 - count: {}", db.countClass( "Person" ) );
>    addPerson( "test1" );
>    addPerson( "test2" );
>    db.commit();
>    log.info( "1 - count: {}", db.countClass( "Person" ) );
> }
>
> private void addPerson( String name )
> {
>    db.begin();
>    log.info( "0 - count: {}", db.countClass( "Person" ) );
>    new ODocument( "Person" ).field( "Name", name ).save();
>    db.commit();
>    log.info( "1 - count: {}", db.countClass( "Person" ) );
> }
>
>
> We see this output:
>
> 2015-02-13 20:12:19,819 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 0 - count: 0
> 2015-02-13 20:12:19,828 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 0 - count: 0
> 2015-02-13 20:12:19,829 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 1 - count: 0
> 2015-02-13 20:12:19,830 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 0 - count: 0
> 2015-02-13 20:12:19,830 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 1 - count: 0
> 2015-02-13 20:12:19,834 INFO  [main] <> com.vertex.orientdb.UpgraderTest - 
> 1 - count: 2
>
>
> The changes made in the first call to addPerson() dont seem visible in the 
> second call, so how would we do multi-step SQL executions in a 
> transactional manner where step 2 referenced stuff from step 1?
>
> Nick
>

-- 

--- 
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.

Reply via email to