Solved

how do I use jdo deletepersistenceall

Posted on 2011-02-20
1
681 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
1 Comment
 
LVL 47

Accepted Solution

by:
for_yan earned 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 36
JAVA part two 5 41
site launch date and last modified date 3 54
Adoquery sql  left join does not work 25 49
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now