Solved

how do I use jdo deletepersistenceall

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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run AutoHotkey script directly from Notepad++ 5 139
junit as external jar or library 7 38
Programming Language for Wordpress 7 63
statistics basics sources 2 38
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

749 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