title: How to get text from app engine datastore?
body: <p>Can someone please tell me how to get a Text value out of a Google App Engine datastore using Java?  I have some entities in the datastore with a Text property named longDescription.  When I try this:</p>
  
  <pre><code>DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
  Query q = new Query("Items");
  PreparedQuery pq = ds.prepare(q);
  for (Entity result : pq.asIterable()) {
      Text longDescription = (Text)result.getProperty("longDescription");
  }
  </code></pre>
  
  <p>I'm getting this warning on the longDescription assignment line:</p>
  
  <pre><code>WARNING: /pstest
  java.lang.ClassCastException: java.lang.String cannot be cast to
      com.google.appengine.api.datastore.Text
  </code></pre>
  
  <p>I'm absolutely bumfuzzled here.  The <em>only</em> string in my code is the literal "longDescription" that is used to fetch the correct property.  If I put this just above the assignment line:</p>
  
  <pre><code>log.warning("Type is " + (result.getProperty("longDescription")).getClass());
  </code></pre>
  
  <p>I see the following output:</p>
  
  <pre><code>WARNING: Type is class com.google.appengine.api.datastore.Text
  </code></pre>
  
  <p>Okay, so result.getProperty("longDescription") really, really is a Text object that is being passed back as an object.  I've even tried using the fully qualified name (com.google.appengine.api.datastore.Text) instead of just Text with the same results.  Where is the String cast coming in?  And more importantly, how do I get that Text out of the datastore?  I'm at my wit's end here, and any help would be appreciated!</p>
  
  <p>Oh, one other possibly relevant note: This is the assignment I used when inserting the property into the datastore:</p>
  
  <pre><code>Entity eItem = new Entity("Items");
  eItem.setProperty("longDescription", new Text(req.getParameter("ldes")));
  ds.put(eItem);
  </code></pre>
  
  <p>When I look at the description in my management console, it seems to be over 500 characters, and it's displayed like this:</p>
  
  <pre><code>&lt;Text: This is a long form description of an item in the store that is access...&gt;
  </code></pre>
  
  <p>Did I screw something up when inserting it?  If so, how do you insert Text items into the datastore?</p>