You might have more luck posting in the Java forum, but in python
query.get would return the first result or None:
http://code.google.com/appengine/docs/python/datastore/queryclass.html#Query_get

On May 20, 1:29 am, Arjun <arumugamar...@gmail.com> wrote:
> public static Employee getEmp(String name){
> List<Employee> lst=null;
> PersistenceManager pm = PMF.get().getPersistenceManager();
> try {
> Query query=pm.newQuery(Employee.class);
> query.setFilter("Name == NameParam");
> query.declareParameters("String NameParam");
> lst = (List<Employee>)query.execute(name);
> lst.size();} catch (JDOObjectNotFoundException e) {
>
> pm.close();
> return null;}finally{
> pm.close();
> }
>
> if(lst.isEmpty())
> return null;
> return lst.get(0);
>
> }
>
> In the above function the employee with the name provided as the
> parameter will be returned. The Name field is not a primary key hence
> i used the Query to fetch the result.
> Since the query.execute() function returns the result of type
> List<Employee> i have to use many lines of coding.
> Is there any other way to fetch a single result i.e a result of type
> Employee not List<Employee> using the query object ?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to google-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-appengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to