Package com.google.appengine.api.datastore

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


    recorder.beginTransaction(transactionOptions);
    return new TransactionRecordingImpl(txn, txnRecorder);
  }

  public Transaction getCurrentTransaction() {
    Transaction t1 = recorder.getCurrentTransaction();
    Transaction t2 = delegate.getCurrentTransaction();
    if (t1 == null || t2 == null) {
      return null;
    }
    return new TransactionRecordingImpl(t1, t2);
  }
View Full Code Here


    }
    return new TransactionRecordingImpl(t1, t2);
  }

  public Transaction getCurrentTransaction(Transaction txn) {
    Transaction t1 = recorder.getCurrentTransaction(txn);
    Transaction t2 = delegate.getCurrentTransaction(txn);
    if (t1 == null || t2 == null) {
      return null;
    }
    return new TransactionRecordingImpl(t1, t2);
  }
View Full Code Here

    Band band2 = new Band();
    band2.name = "Chemical Brothers";

    datastore.storeAll(Arrays.asList(band1, band2));

    Transaction txn = datastore.beginTransaction();

    // overwrite band1
    Band band3 = new Band();
    band3.name = "Kasier Chiefs";
    datastore.store().instance(band3);
    txn.commit();

    txn = datastore.beginTransaction();
    Band band4 = new Band();
    band4.name = "Kasier Chiefs";

    boolean threw = false;
    try
    {
      datastore.store().instance(band4).ensureUniqueKey().returnKeyNow();
    }
    catch (Exception e)
    {
      threw = true;
      }
    txn.rollback();
    assertTrue(threw);
  }
View Full Code Here

    };
  }

  private Future<QueryResultIterator<Entity>> futureSingleQueryEntities(Query query)
  {
      Transaction txn = this.datastore.getTransaction();
      Future<QueryResultIterator<Entity>> futureEntities;
      AsyncPreparedQuery prepared = new AsyncPreparedQuery(query, txn);
      FetchOptions fetchOptions = getRootCommand().getFetchOptions();
      if (fetchOptions == null)
      {
View Full Code Here

  private List<Future<QueryResultIterator<Entity>>> multiQueriesToFutureEntityIterators(
      Collection<Query> queries)
  {
    final List<Future<QueryResultIterator<Entity>>> futures = new ArrayList<Future<QueryResultIterator<Entity>>>(queries.size());
    Transaction txn = datastore.getTransaction();
    for (Query query : queries)
    {
      AsyncPreparedQuery prepared = new AsyncPreparedQuery(query, txn);
      Future<QueryResultIterator<Entity>> futureEntities;
      FetchOptions fetchOptions = getRootCommand().getFetchOptions();
View Full Code Here

  @Test
  public void testGetTxn() {

    persiter = objectifyFactory.beginTransaction();

    Transaction txn = persiter.getTxn();

    assertNotNull(txn);

  }
View Full Code Here

      Entity hasParentKeyPkEntity =
          new Entity(HasOneToOneParentKeyPkJPA.class.getSimpleName(), pojoEntity.getKey());
      hasParentKeyPkEntity.setProperty("str", "yag");
      ds.put(hasParentKeyPkEntity);

      Transaction txn = EasyMock.createMock(Transaction.class);
      EasyMock.expect(txn.getId()).andReturn("1").times(2);
      txn.commit();
      EasyMock.expectLastCall();
      EasyMock.replay(txn);
      EasyMock.expect(mockDatastore.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(txn);
      // the only get we're going to perform is for the pojo
      EasyMock.expect(mockDatastore.get(txn, pojoEntity.getKey())).andReturn(pojoEntity);
View Full Code Here

      Entity bidirEntity = new Entity(bidirClass.getSimpleName(), pojoEntity.getKey());
      bidirEntity.setProperty("childVal", "yap");
      ds.put(bidirEntity);

      Transaction txn = EasyMock.createMock(Transaction.class);
      EasyMock.expect(txn.getId()).andReturn("1").times(2);
      txn.commit();
      EasyMock.expectLastCall();
      EasyMock.replay(txn);
      EasyMock.expect(mockDatastore.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(txn);
      // the only get we're going to perform is for the pojo
      EasyMock.expect(mockDatastore.get(txn, pojoEntity.getKey())).andReturn(pojoEntity);
View Full Code Here

      Entity bidirEntity = new Entity(bidirClass.getSimpleName(), pojoEntity.getKey());
      bidirEntity.setProperty("childVal", "yap");
      ds.put(bidirEntity);

      Transaction txn = EasyMock.createMock(Transaction.class);
      EasyMock.expect(txn.getId()).andReturn("1").times(2);
      txn.commit();
      EasyMock.expectLastCall();
      EasyMock.replay(txn);
      EasyMock.expect(mockDatastore.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(txn);
      // the only get we're going to perform is for the pojo
      EasyMock.expect(mockDatastore.get(txn, pojoEntity.getKey())).andReturn(pojoEntity);
View Full Code Here

      Entity bidirEntity = new Entity(bidirClass.getSimpleName(), pojoEntity.getKey());
      bidirEntity.setProperty("childVal", "yap");
      ds.put(bidirEntity);

      Transaction txn = EasyMock.createMock(Transaction.class);
      EasyMock.expect(txn.getId()).andReturn("1").times(2);
      txn.commit();
      EasyMock.expectLastCall();
      EasyMock.replay(txn);
      EasyMock.expect(mockDatastore.beginTransaction(EasyMock.isA(TransactionOptions.class))).andReturn(txn);
      // the only get we're going to perform is for the pojo
      EasyMock.expect(mockDatastore.get(txn, pojoEntity.getKey())).andReturn(pojoEntity);
View Full Code Here

TOP

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

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.