Let's say you have a Profile entity with an id of 123. The easiest
way to retrieve it is to use DatastoreService.get(), not a query.
Construct a Key and pass that to get():
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key key = KeyFactory.createKey("Profile", 123L);
Entity ent = ds.get(key);
Jeff
On Thu, Mar 22, 2012 at 5:34 PM, Aribar Hunter <[email protected]> wrote:
> I feel stupid. I've looked over lots of documentation, I've tried Google
> searches, I've searched on other sites like Stackoverflow, and I just don't
> understand this.
>
> I have a site that allows the user to access "profiles" of imaginary people
> containing information like names and descriptions. I have links dynamically
> put on the side bar for each profile in my datastore. The links look like
> "profile.jsp?id=1", replacing 1 with whatever id that profile is.
>
> I want to try and display the information in profile.jsp that relates to the
> id, or key, that's in the url. The thing is, I don't know how to structure
> the query. I've seen things about JDO/JDA and queries that look a lot like
> SQL on other forms, but I have no idea what those people are actually doing.
> This is the closest I've come to making this work, but it just returns
> nothing:
>
> <%
> Query query = new Query("Entry");
> query.addFilter("Key", Query.FilterOperator.EQUAL,
> request.getParameter("id"));
> PreparedQuery pq = datastore.prepare(query);
> %>
> End User: <%= pq.asSingleEntity().getProperty("name") %>
>
> What I think I'm doing is making a Query for the Kind with all the
> information, then filtering that id should equal whatever is in the Key
> spot... But that doesn't seem to be the case. Any help would be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine-java/-/t5OcxJUjLAgJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.