Solved

how do I use jdo deletepersistenceall

Posted on 2011-02-20
1
700 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

622 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