private void testMultiStatement(){
  MVStore s=MVStore.open(null);
  TransactionStore ts=new TransactionStore(s);
  ts.init();
  Transaction tx;
  TransactionMap<String,String> m;
  long startUpdate;
  tx=ts.begin();
  startUpdate=tx.setSavepoint();
  m=tx.openMap("test");
  m.setSavepoint(startUpdate);
  startUpdate=tx.setSavepoint();
  m.setSavepoint(startUpdate);
  assertTrue(m.trySet("1","Hello",true));
  assertTrue(m.trySet("2","World",true));
  assertNull(m.get("1"));
  assertNull(m.get("2"));
  startUpdate=tx.setSavepoint();
  m.setSavepoint(startUpdate);
  assertEquals("Hello",m.get("1"));
  assertEquals("World",m.get("2"));
  assertEquals("Hello",m.get("1"));
  assertTrue(m.trySet("1",null,true));
  assertTrue(m.trySet("2","Hello",true));
  assertEquals("World",m.get("2"));
  assertTrue(m.trySet("2",null,true));
  assertTrue(m.trySet("3","World",true));
  assertEquals("Hello",m.get("1"));
  assertEquals("World",m.get("2"));
  assertNull(m.get("3"));
  startUpdate=tx.setSavepoint();
  m.setSavepoint(startUpdate);
  assertNull(m.get("1"));
  assertEquals("Hello",m.get("2"));
  assertEquals("World",m.get("3"));
  startUpdate=tx.setSavepoint();
  m.setSavepoint(startUpdate);
  assertTrue(m.trySet("2",null,true));
  assertTrue(m.trySet("1","Hello",true));
  assertTrue(m.trySet("3",null,true));
  assertFalse(m.trySet("1","World",true));
  tx.rollbackToSavepoint(startUpdate);
  startUpdate=tx.setSavepoint();
  m.setSavepoint(startUpdate);
  assertNull(m.get("1"));
  assertEquals("Hello",m.get("2"));
  assertEquals("World",m.get("3"));
  tx.commit();
  ts.close();
  s.close();
}

private void testMultiStatement ( ) { MVStore s = MVStore . open ( null ) ; TransactionStore ts = new TransactionStore ( s ) ; ts . init ( ) ; Transaction tx ; TransactionMap < String , String > m ; long startUpdate ; tx = ts . begin ( ) ; startUpdate = tx . setSavepoint ( ) ; m = tx . openMap ( "test" ) ; m . setSavepoint ( startUpdate ) ; startUpdate = tx . setSavepoint ( ) ; m . setSavepoint ( startUpdate ) ; assertTrue ( m . trySet ( "1" , "Hello" , true ) ) ; assertTrue ( m . trySet ( "2" , "World" , true ) ) ; assertNull ( m . get ( "1" ) ) ; assertNull ( m . get ( "2" ) ) ; startUpdate = tx . setSavepoint ( ) ; m . setSavepoint ( startUpdate ) ; assertEquals ( "Hello" , m . get ( "1" ) ) ; assertEquals ( "World" , m . get ( "2" ) ) ; assertEquals ( "Hello" , m . get ( "1" ) ) ; assertTrue ( m . trySet ( "1" , null , true ) ) ; assertTrue ( m . trySet ( "2" , "Hello" , true ) ) ; assertEquals ( "World" , m . get ( "2" ) ) ; assertTrue ( m . trySet ( "2" , null , true ) ) ; assertTrue ( m . trySet ( "3" , "World" , true ) ) ; assertEquals ( "Hello" , m . get ( "1" ) ) ; assertEquals ( "World" , m . get ( "2" ) ) ; assertNull ( m . get ( "3" ) ) ; startUpdate = tx . setSavepoint ( ) ; m . setSavepoint ( startUpdate ) ; assertNull ( m . get ( "1" ) ) ; assertEquals ( "Hello" , m . get ( "2" ) ) ; assertEquals ( "World" , m . get ( "3" ) ) ; startUpdate = tx . setSavepoint ( ) ; m . setSavepoint ( startUpdate ) ; assertTrue ( m . trySet ( "2" , null , true ) ) ; assertTrue ( m . trySet ( "1" , "Hello" , true ) ) ; assertTrue ( m . trySet ( "3" , null , true ) ) ; assertFalse ( m . trySet ( "1" , "World" , true ) ) ; tx . rollbackToSavepoint ( startUpdate ) ; startUpdate = tx . setSavepoint ( ) ; m . setSavepoint ( startUpdate ) ; assertNull ( m . get ( "1" ) ) ; assertEquals ( "Hello" , m . get ( "2" ) ) ; assertEquals ( "World" , m . get ( "3" ) ) ; tx . commit ( ) ; ts . close ( ) ; s . close ( ) ; }
tests behavior when used for a sequence of sql statements . each statement uses a savepoint . within a statement , changes by the statement itself are not seen ; the change is only seen when the statement finished . < p > update statements that change the key of multiple rows may use delete / add pairs to do so ( they don ' t need to first delete all entries and then re - add them ) . trying to add multiple values for the same key is not allowed ( an update statement that would result in a duplicate key ) .
