Package com.googlecode.objectify

Examples of com.googlecode.objectify.VoidWork


    if (!isLocked) {
      return;
    }
   
    try {
      Ofy.transactNew(new VoidWork() {

        @Override
        public void vrun() {
          Ofy.delete().type(FieldValueLock.class).id(
              fieldValue).now();
View Full Code Here


    final Trivial triv = new Trivial(123L, "foo", 5);

    try (Closeable root = TestObjectifyService.begin()) {

      ofy().transact(new VoidWork() {
        @Override
        public void vrun() {
          ofy().defer().save().entity(triv);

          // Can load out of session
          assertThat(ofy().load().entity(triv).now(), is(triv));

          // But not datastore
          try {
            ds().get(null, Key.create(triv).getRaw());
            assert false : "Entity should not have been saved yet";
          } catch (EntityNotFoundException e) {
            // correct
          }
        }
      });

      {
        Trivial loaded = ofy().load().entity(triv).now();
        assertThat(loaded, equalTo(triv));
      }

      ofy().transact(new VoidWork() {
        @Override
        public void vrun() {
          ofy().defer().delete().entity(triv);

          // Deleted in session
View Full Code Here

    final Key<HasSingle> hskey = ofy().save().entity(hs).now();

    ofy().clear();

    // Load hs in a transaction, which will then propagate back to parent session
    ofy().transact(new VoidWork() {
      @Override
      public void vrun() {
        ofy().load().key(hskey).now();
      }
    });
View Full Code Here

    final Key<HasSingle> hskey = ofy().save().entity(hs).now();

    ofy().clear();

    // Load hs in a transaction, which will then propagate back to parent session, including the Ref async load
    ofy().transact(new VoidWork() {
      @Override
      public void vrun() {
        ofy().load().group(Single.class).key(hskey).now();
      }
    });
View Full Code Here

    final Key<HasSingle> hskey = ofy().save().entity(hs).now();

    ofy().clear();

    // Load hs in a transaction, which will then propagate back to parent session, including the Ref async load
    ofy().transact(new VoidWork() {
      @Override
      public void vrun() {
        ofy().load().group(Single.class).key(hskey).now();
      }
    });
View Full Code Here

    Trivial triv = new Trivial("foo", 5);
    final Key<Trivial> tk = ofy().save().entity(triv).now();

    try {
      ofy().transactNew(2, new VoidWork() {
        @Override
        public void vrun() {
          Trivial triv1 = ofy().transactionless().load().key(tk).now();
          Trivial triv2 = ofy().load().key(tk).now();
View Full Code Here

  @Test
  public void testTransactionRollback() throws Exception {
    fact().register(Trivial.class);

    try {
      ofy().transact(new VoidWork() {
        @Override
        public void vrun() {
          Trivial triv = new Trivial("foo", 5);
          ofy().save().entity(triv).now();
          throw new RuntimeException();
View Full Code Here

   * This is a somewhat clunky way to test this, and requires making impl.getCache() public,
   * but it gets the job done.
   */
  @Test
  public void transactionalObjectifyInheritsCacheSetting() throws Exception {
    ofy().cache(false).transact(new VoidWork() {
      @Override
      public void vrun() {
        // Test in _and out_ of a transaction
        ObjectifyImpl<?> txnlessImpl = (ObjectifyImpl<?>)ofy().transactionless();
        assert !txnlessImpl.getCache();
View Full Code Here

 
  /**
   */
  @Test
  public void executeMethodWorks() throws Exception {
    ofy().execute(TxnType.REQUIRED, new VoidWork() {
      @Override
      public void vrun() {
        assert ofy().load().type(Trivial.class).id(123L).now() == null;
      }
    });
View Full Code Here

  final WikiPlace wikiPlace;

  @Override
  public void run() {

    ofy().transact(new VoidWork() {
      @Override
      public void vrun() {
        log.debug("Syncing " + wikiPlace);

        Place place = ofy().load().type(Place.class).id(wikiPlace.getId()).now();
View Full Code Here

TOP

Related Classes of com.googlecode.objectify.VoidWork

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.