Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Key


  @Test
  public void testClearing()
  {
    ObjectStoreCache cache = new ObjectStoreCache();

    Key key = KeyFactory.createKey("fred", 12);
    Foo object = new Foo();

    cache.set(object, key);

    assertEquals(object, cache.getObject(key));
View Full Code Here


    f.i = RandomUtils.nextInt();
    f.l = RandomUtils.nextLong();
    f.f = RandomUtils.nextFloat();
    f.d = RandomUtils.nextDouble();

    Key key = os.beginSession().store(f).now();

    Foo g = os.beginSession().load(key).now();
    assertEquals(f.b, g.b);
    assertEquals(f.c, g.c);
    assertEquals(f.s, g.s);
View Full Code Here

  @Test
  public void testEvenutalConsistency() throws Exception
  {
    ObjectStore os = ObjectStore.Factory.create();
    Key key = os.beginSession().store(new Foo()).now();
   
    try
    {
      os.beginSession().load(key).retries(0).now();
      assertTrue(false); // should have thrown
View Full Code Here

  @Test
  public void testCustomPropertyEncoder() throws Exception
  {
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    LongEncodedEntity e = new LongEncodedEntity();
    Key key = oss.store(e).now();
    Point orig = e.p;
    Long l = new PointLongEncoder().encode(orig);
   
    e.p = null;
    oss.refresh(e).now();
View Full Code Here

    a.bs.add(new B("Fred"));
    a.bs.add(null);
    a.bs.add(new B("Sally"));
   
    ObjectStore os = ObjectStore.Factory.create();
    Key key = os.beginSession().store(a).now();
   
    A a2 = os.beginSession().load(key).now();
   
    assertEquals(a.bs, a2.bs);
  }
View Full Code Here

  @Test
  public void testUnactivatedLoad()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    Key key = oss.store(new Foo("Fred Flintstone")).now();

    ObjectStoreSession oss2 = os.beginSession();
    Foo foo = oss2.load(key).unactivated().now();
    assertTrue(foo.name == null);
    assertEquals(key, oss2.getKey(foo));
View Full Code Here

    a.bs.add(b2);
   
    ObjectStore os = ObjectStore.Factory.create();
    os.register(B1.class.getSimpleName(), B1.class);
    os.register(B2.class.getSimpleName(), B2.class);
    Key key = os.beginSession().store(a).now();
   
    A a2 = os.beginSession().load(key).now();
    assertEquals(a, a2);
   
    Entity e = DatastoreServiceFactory.getDatastoreService().get(key);
View Full Code Here

    p1.firstName = "Fred";
    p1.lastName = "Flintstone";
    p1.shoeSize = 12L;

    Key key = os.store(p1).id(33L).now();
    assertEquals(33L, key.getId());
   
    ObjectStoreSession os2 = osf.beginSession();
    Person p2 = (Person) os2.load(Person.class).id(33L).now();

    assertTrue(p2 != p1);
View Full Code Here

  @Test
  public void testLoadSingleKey()
  {
    ObjectStore os = ObjectStore.Factory.create();

    Key key = os.beginSession().store(new X()).now();

    assertEquals(X.class, os.beginSession().load(key).now().getClass());
  }
View Full Code Here

  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    X x = new X();
    x.blah = "fred";
    Key key = oss.store(x).now();
    x.blah = "mary";
    assertEquals("mary", oss.load(key).<X> now().blah);
    assertEquals("fred", oss.load(key).refresh().<X> now().blah);
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Key

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.