Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how do I use jdo deletepersistenceall

Posted on 2011-02-20
1
Medium Priority
?
703 Views
Last Modified: 2013-11-13
My code;
  Query q = pm.newQuery(Sentences.class,"this.id > 5");

    Collection c = (Collection)q.execute();
      System.out.println("Size "+c.size());
    pm.deletePersistentAll(c);

Error message:
Illegal argument
org.datanucleus.store.appengine.FatalNucleusUserException: Illegal argument
0
Comment
Question by:fblack61
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 47

Accepted Solution

by:
for_yan earned 200 total points
ID: 34938395
Check the paragraph below on this page:
http://code.google.com/appengine/docs/java/datastore/jdo/queries.html#Delete_By_Query

They are saying that INSTEAD OF execute they do deletePersistentAll - not after it


Deleting Entities By Query

If you are issuing a query with the goal of deleting all the entities that match the query filter, you can save yourself a bit of coding by using JDO's "delete by query" feature. The following deletes all People over a given height:

    Query query = pm.newQuery(Person.class);
    query.setFilter("height > maxHeightParam");
    query.declareParameters("int maxHeightParam");
    query.deletePersistentAll(maxHeight);

You'll notice that the only difference here is that instead of calling query.execute(...) we are instead calling query.deletePersistentAll(...). All of the rules and restrictions relating to filters, sort orders, and indexes explained above apply to queries whether you are selecting or deleting the result set. Note, however, that just as if you had deleted these Person entities with pm.deletePersistent(...), any dependent children of the entities deleted by the query will also be deleted. For more information on dependent children please see Dependent Children and Cascading Deletes.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question