title: How to use transactions in Cloud Datastore
body: <p>I want to use Datastore from Cloud Compute through Java and I am following <a href="https://cloud.google.com/datastore/docs/getstarted/start_java/" rel="nofollow">Getting started with Google Cloud Datastore</a>.</p>
  
  <p>My use case is quite standard - read one entity (lookup), modify it and save the new version. I want to do it in a transaction so that if two processes do this, the second one won't overwrite the changes made by the first one.</p>
  
  <p>I managed to issue a transaction and it works. However I don't know what would happen if the transaction fails:</p>
  
  <ul>
  <li>How to identify a failed transaction? Probably a DatastoreException with some specific code or name will be thrown?</li>
  <li>Should I issue a rollback explicitly? Can I assume that if a transaction fails, nothing from it will be written?</li>
  <li>Should I retry?</li>
  <li>Is there any documentation on that?</li>
  </ul>