Package com.google.appengine.api.datastore

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


  {
    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.refresh(x).now().blah);
  }
View Full Code Here


    return value;
  }

  public Key put(Transaction arg0, Entity arg1)
  {
    Key key = arg1.getKey();

    if (!key.isComplete())
      key = KeyFactory.createKey(key.getParent(), key.getKind(), getNext(key.getKind()));

    store.put(key.toString(), arg1);

    return key;
  }
View Full Code Here

    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();
   
View Full Code Here

    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();
View Full Code Here

    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();
View Full Code Here

    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();
View Full Code Here

        }
      } else {
        return r.withWarning(ErrorCode.W125);
      }
    } else if (this.ops.size() % 2 == 0) { //TODO KEY('kind', 'name'/ID [, 'kind', 'name'/ID...])
      Key key = null;
     
      // evaluation results, used at last to construct all previous results
      List<EvaluationResult> rs = new ArrayList<EvaluationResult>(this.ops.size());
     
      Iterator<Evaluator> i = this.ops.iterator();
View Full Code Here

    assertEquals(namespace == null ? "" : namespace, query.getNamespace());
  }

  public void testCreateReadersWithAncestor() throws IOException {
    List<Key> data = populateData(2, null);
    Key parrent = data.get(0);
    Key notInResult = data.get(1);
    List<Key> keys = populateData(100, null, parrent);
    DatastoreInput input = new DatastoreInput(new Query(ENTITY_KIND_NAME, parrent), 5);
    ArrayList<Key> read = new ArrayList<>();
    for (InputReader<Entity> reader : input.createReaders() ) {
      read.addAll(getEntities(reader));
View Full Code Here

      throws IOException {
    reader.beginShard();
    reader.beginSlice();
    ArrayList<Key> read = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      Key key = reader.next();
      read.add(key);
    }
    try {
      reader.next();
      fail("Expected NoSuchElementException");
    } catch (NoSuchElementException expected) {
      //
    }
    reader.endSlice();
    reader.endShard();
    Collections.sort(read);
    for (int i = 0; i < size; i++) {
      Key key = read.get(i);
      assertEquals("key_" + i, key.getName());
      assertEquals(namespace, key.getNamespace());
    }
  }
View Full Code Here

    helper.tearDown();
    super.tearDown();
  }

  public void testOneEntityOnly() throws Exception {
    Key key = populateData(1, null).get(0);
    DatastoreInputReader reader = new DatastoreInputReader(all);
    reader.beginSlice();
    assertEquals(key, reader.next().getKey());
    try {
      reader.next();
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.