title: How to get objectify reference (Ref<T>) object to entity while executing a query on appengine datastore?
body: <p>While upgrading Objectify in an Appengine Java-based application, I got stuck with a problem and here is a solution, I have tried to solve this but not sure how good it is?</p>
  <p>The problem was
  In the older version (Objectify 4.0b2), a query returned a Reference to the DB object.</p>
  <pre><code>Ref&lt;EntityDO&gt; refEntity = ofy().load().type(EntityDO.class).id(entityId);
  </code></pre>
  <p>This used to be a valid code as ofy().load().type().id() used to return a reference to the DB entity.</p>
  <p>After upgrading Objectify to a later version, this has changed to</p>
  <pre><code>LoadResult&lt;EntityDO&gt; entityDO = ofy().load().type(EntityDO.class).id(entityId);
  </code></pre>
  <p>Now I used this code to convert the LoadResult&lt;&gt; object to Ref&lt;&gt; object.</p>
  <pre><code>  public static &lt;T&gt; Ref&lt;T&gt; getRef(LoadResult&lt;T&gt; loadResult) {
      if (loadResult != null) {
        T obj = loadResult.now();
        if (obj != null) {
          return Ref.create(obj);
        }
      }
      return null;
    }
  </code></pre>
  <p>With this, I am able to get the Ref&lt;&gt; object successfully. My concern here is is this a good approach where to create a Ref&lt;&gt; object, we fetch the object from DB?</p>
  <p>Thanks
  Aadhaar</p>