Hi Simon,

This is what I do. First I load it, then delete it.
  ThingJdo ttj2 = (ThingJdo) pm.getObjectById(ThingJdo.class,
ttj.getThingId());
  pm.deletePersistent(ttj2);

http://code.google.com/p/gwt-examples/source/browse/trunk/Core/src/org/gonevertical/core/server/jdo/data/ThingJdo.java#552
- reference to my code
public boolean delete(ThingData thingData) {

                if (thingData == null) {
                        return false;
                }

                if (thingData.getThingId() == 0) {
                        return false;
                }

                // delete child objects that the thing owns first
                deleteSub(thingData);

                ThingJdo ttj = new ThingJdo(sp);
                ttj.setData(thingData);

                PersistenceManager pm = sp.getPersistenceManager();
                Transaction tx = pm.currentTransaction();
                boolean b = false;
                try {
                        tx.begin();
                        ThingJdo ttj2 = (ThingJdo)
pm.getObjectById(ThingJdo.class, ttj.getThingId());
                        pm.deletePersistent(ttj2);
                        tx.commit();
                        b = true;
                } catch (Exception e) {
                        e.printStackTrace();
                        b = false;
                } finally {
                        if (tx.isActive()) {
                                tx.rollback();
                                b = false;
                        }
                        pm.close();
                }

                return b;
        }

http://code.google.com/p/gwt-examples/ - more examples with demos and
source here.

Hope that helps,
Brandon


On Aug 30, 11:34 am, Simon <[email protected]> wrote:
> Hi!
>
> I'm trying to delete an object by using the key id.
>
> I'm using an automatically generated key;
>
> <code>
>     @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     private Key key;
> </code>
>
> What is the best way to delete an object with a specific id?
>
> I'm using Java, and had it working a while ago by doing;
> "WHERE __key__=Key('type', id)
>
> But now it tells me that = is an invalid operator.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to