title: Objectify BATCH delete has no effect
body: <p>I have a DAO below, with a transactional delete <strong>per entity</strong> and <strong>in batch</strong>. 
  Deleting one entity at a time works just fine. </p>
  
  <p>Batch delete has NO effect whatsoever : 
  the code below is simple and straightforward IMO, but the call to <strong>deleteMyObjects(Long[] ids)</strong> - which calls <strong>delete(Iterable keysOrEntities)</strong> of <strong>Objectify</strong> - has no effect !</p>
  
  <pre><code>public class MyObjectDao {
  
      private ObjectifyOpts transactional = new ObjectifyOpts().setBeginTransaction(true);
  
      private ObjectifyOpts nonTransactional = new ObjectifyOpts().setBeginTransaction(false);
  
      private String namespace = null;
  
      public MyObjectDao(String namespace) {
          Preconditions.checkNotNull(namespace, "Namespace cannot be NULL");
          this.namespace = namespace;
      }
  
      /**
       * set namespace and get a non-transactional instance of Objectify
       * 
       * @return
       */
      protected Objectify nontxn() {
          NamespaceManager.set(namespace);
          return ObjectifyService.factory().begin(nonTransactional);
      }
  
      /**
       * set namespace and get a transactional instance of Objectify
       * 
       * @return
       */
      protected Objectify txn() {
          NamespaceManager.set(namespace);
          Objectify txn =  ObjectifyService.factory().begin(transactional);
          log.log(Level.FINE, "transaction &lt;" + txn.getTxn().getId() + "&gt; started");
          return txn;
      }
  
      protected void commit(Objectify txn) {
          if (txn != null &amp;&amp; txn.getTxn().isActive()) {
              txn.getTxn().commit();
              log.log(Level.FINE, "transaction &lt;" + txn.getTxn().getId() + "&gt; committed");
          } else {
              log.log(Level.WARNING, "commit NULL transaction");
          }
      }
  
      protected void rollbackIfNeeded(Objectify txn) {
          if (txn != null &amp;&amp; txn.getTxn() != null &amp;&amp; txn.getTxn().isActive()) {
              log.log(Level.WARNING, "transaction &lt;" + txn.getTxn().getId() + "&gt; rolling back");
              txn.getTxn().rollback();
          } else if (txn == null || txn.getTxn() == null) {
              log.log(Level.WARNING, "finalizing NULL transaction, not rolling back");
          } else if (!txn.getTxn().isActive()) {
              log.log(Level.FINEST, "transaction &lt;" + txn.getTxn().getId() + "&gt; NOT rolling back");
          }
      }
  
  
      public void deleteMyObject(Long id) {
          Objectify txn = null;
          try {
              txn = txn();
              txn.delete(new Key&lt;MyObject&gt;(MyObject.class, id));
              commit(txn);
          } finally {
              rollbackIfNeeded(txn);
          }
      }
  
      public void deleteMyObjects(Long[] ids) {
          Objectify txn = null;
          List&lt;Key&lt;? extends MyObject&gt;&gt; keys = new ArrayList&lt;Key&lt;? extends MyObject&gt;&gt;();
          for (long id : ids) {
              keys.add(new Key&lt;MyObject&gt;(MyObject.class, id));
          }
          try {
              txn = txn();
              txn.delete(keys);
              commit(txn);
          } finally {
              rollbackIfNeeded(txn);
          }
      }
  }
  </code></pre>
  
  <p>When I call deleteMyObjects(Long[] ), I see nothing suspicious in the logs below. The transaction commits just fine without errors. But the data is not effected. Looping through the same list of Ids and deleting the objects one at a time, works just fine.</p>
  
  <pre><code>Feb 29, 2012 8:37:42 AM com.test.MyObjectDao txn
  FINE: transaction &lt;6&gt; started
  Feb 29, 2012 8:37:42 AM com.test.MyObjectDao commit
  FINE: transaction &lt;6&gt; committed
  Feb 29, 2012 8:37:42 AM com.test.MyObjectDao rollbackIfNeeded
  FINEST: transaction &lt;6&gt; NOT rolling back
  </code></pre>
  
  <p>But the data is unchanged and present in the datastore !?!?!</p>
  
  <p>Any help welcome.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Stepping into the Objectify code, I wonder wether this has something to do with the namespace ? Right here in the objectify code :</p>
  
  <pre><code>@Override
  public Result&lt;Void&gt; delete(Iterable&lt;?&gt; keysOrEntities)
  {
      // We have to be careful here, objs could contain raw Keys or Keys or entity objects or both!
      List&lt;com.google.appengine.api.datastore.Key&gt; keys = new ArrayList&lt;com.google.appengine.api.datastore.Key&gt;();
  
      for (Object obj: keysOrEntities)
          keys.add(this.factory.getRawKey(obj));
  
      return new ResultAdapter&lt;Void&gt;(this.ads.delete(this.txn, keys));
  }
  </code></pre>
  
  <p>When I inspect <strong>this.factory.getRawKey(obj)</strong> in debug, I notice that the namespace of the key is empty. <strong>NamespaceManager.get()</strong> however returns the correct namespace !?</p>
  
  <p><img src="https://i.stack.imgur.com/9N3AU.png" alt="enter image description here"></p>