Try this

PersistenceManager pm = PMF.get().getPersistenceManager();
Key key = KeyFactory.createKey(Marker.class.getSimpleName(),
marker_id);

Query query = persistenceManager.newQuery(Marker.class);
query.setFilter("marker_id == keyParam");
query.declareImports("import
com.google.appengine.api.datastore.Key;");
query.declareParameters("Key keyParam");

try{
    query.deletePersistentAll(key);
} finally {
    query.closeAll();
    persistenceManager.close();
}

On Aug 3, 12:20 pm, sanja <[email protected]> wrote:
> What error do you get?
>
> On Aug 1, 11:06 am, Sap_junior <[email protected]> wrote:
>
> > Hello !
>
> > I have a problem with retriving objects by Key.  I searched this error
> > in google , but  didn't find any useful information about it.
>
> > Here is the code:
>
> > @PersistenceCapable
> > public class Marker {
> >         @PrimaryKey
> >         @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >         private Key marker_id;
> >         @Persistent
> >         private String marker_name;
> >         @Persistent
> >         private Double marker_lat;
> >         @Persistent
> >         private Double marker_lng;
> >         @Persistent
> >         private String marker_address;
> >         @Persistent
> >         private String marker_content;
> > .....
>
> > }
>
> > Here is the code of the servlet ( which must retrive an object and
> > delete)
>
> > .......
> > String marker_id_str = req.getParameter("marker_id").trim();
> > Long marker_id = null;
>
> >         try{
> >                 marker_id = Long.parseLong(marker_id_str.trim());
> >         }
>
> >         catch(Exception e){
> >                 e.getStackTrace();
> >         }
> > .....
> > Key k = null;
> >         PersistenceManager pm = null;
> >         try{
> >                 k = KeyFactory.createKey(Marker.class.getSimpleName(), 
> > marker_id);
> >                 //Long k = 
> > Long.parseLong(req.getParameter("marker_id").trim());
> >                 pm = PMF.get().getPersistenceManager();
> >                 Marker marker =  pm.getObjectById(Marker.class, k);
> >                 out.println(marker.getMarker_id() + 
> > marker.getMarker_name());
> >                 //pm.deletePersistent(marker);
> >         }
> >         catch(Exception e){
> >                 e.printStackTrace();
> >         }
> >         finally{
> >                 pm.close();
> >         }
> > ........
>
> > I get this error :
>
>

-- 
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.

Reply via email to