Package com.google.code.gaeom

Examples of com.google.code.gaeom.ObjectStoreSession


  @Test
  public void testRefreshMultipleKeys2()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    X x1 = new X();
    x1.blah = "fred1";
    X x2 = new X();
    x2.blah = "fred2";
    X x3 = new X();
    x3.blah = "fred3";
    List<Key> keys = oss.store(x1, x2, x3).now();
    x1.blah = null;
    x2.blah = null;
    x3.blah = null;

    // without refresh
    List<X> same = Lists.newArrayList(oss.load(keys).<X> now());
    assertNull(same.get(0).blah);
    assertNull(same.get(1).blah);
    assertNull(same.get(2).blah);

    List<X> list = Lists.newArrayList(oss.refresh(same).now());

    assertEquals(x1, list.get(0));
    assertEquals(x2, list.get(1));
    assertEquals(x3, list.get(2));
View Full Code Here


  @Test
  public void testLoadSingleParentedStringId()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    X parent = new X();
    oss.store(parent).now();
    oss.store(new X()).id("a").parent(parent).now();

    assertEquals(X.class, oss.load(X.class).id("a").parent(parent).now().getClass());
  }
View Full Code Here

  @Test
  public void testLoadMultipleParentedStringId()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    X parent = new X();
    oss.store(parent).now();
    oss.store(new X(), new X(), new X()).ids("a", "b", "c").parent(parent).now();

    assertEquals(3, oss.load(X.class).ids("a", "b", "c").parent(parent).now().size());
  }
View Full Code Here

  {
    TestCache tc = new TestCache();
    tc.name = "Fred";
   
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss1 = os.beginSession();
   
    Key key = oss1.store(tc).now();
   
    ObjectStoreSession oss2 = os.beginSession();

    TestCache tc2 = (TestCache)oss2.load(key).now();
   
    assertTrue("same instance", tc == tc2);
  }
View Full Code Here

  }
 
  @Test
  public void testGeneratedIdField()
  {
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
   
    LongId o = new LongId();
    o.name = "Fred";
    oss.store(o).now();
   
    assertNotNull(o.id);
    Long id = o.id;
   
    o.id = null;
    o.name = null;
   
    oss.refresh(o).now();
   
    assertEquals(id, o.id);
    assertEquals("Fred", o.name);
  }
View Full Code Here

    a.name = "Fred";
    a.b.name = "Flintstone";

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(a).now();

    ObjectStoreSession oss2 = os.beginSession();

    A a2 = (A) oss2.load(key).now();

    assertEquals(a.name, a2.name);
    assertNotNull(a2.b);
    assertEquals(a.b.name, a2.b.name);
  }
View Full Code Here

    a.name = "Fred";
    a.b.name = "Flintstone";

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(a).now();
    oss.delete(a.b).now();

    ObjectStoreSession oss2 = os.beginSession();

    oss2.load(key).retries(1).now();
    assertTrue(false);
  }
View Full Code Here

    family.addChild(new Person("Sam"));
    family.addChild(new Person("Maggie"));
    family.addChild(new Person("Katy"));

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Key key = oss.store(family).now();

    ObjectStoreSession oss2 = os.beginSession();

    Family family2 = (Family) oss2.load(key).now();

    assertEquals(family.name, family2.name);
    assertEquals(family.heads.size(), family2.heads.size());
    assertEquals(family.children.size(), family2.children.size());
    assertEquals(family.heads.get(0).name, family2.heads.get(0).name);
View Full Code Here

  }

  @Before
  public void load()
  {
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    oss.store(allPeople).now();
  }
View Full Code Here

  }

  @Test
  public void testFindAll()
  {
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    List<Person> people = Lists.newArrayList(oss.find(Person.class).now());
    assertEquals(allPeople, people);
  }
View Full Code Here

TOP

Related Classes of com.google.code.gaeom.ObjectStoreSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.