tags:

views:

49

answers:

3

I'm created Data Class and store data using PersistenceManager, but later I edited my Data Class and now i have problem with share data I'm trying delete this objects (pm.deletePersistent(e)) but I'have exception :

javax.jdo.JDOUserException: One or more instances could not be deleted NestedThrowables: org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "java.lang.Class" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found." is not persistable

that's my Data Class :

import com.google.appengine.api.datastore.Key;
import java.util.ArrayList;
import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable

public class Task {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

    @Persistent
    private String author;

    @Persistent
    private String task;

    @Persistent
    private Date date;

    @Persistent
    private String note;

    @Persistent
    private ArrayList<String> label; 

    @Persistent
    private int numberoflist;





    public Task (String author, String task,String note, Date date, int numberoflist)
    {
        this.author=author;
        this.task=task;
        this.date=date;
        this.numberoflist=numberoflist;
        this.note=note;
    }

that's my .jsp file, but deletePersistentAll(Task.class) or pm.deletePersistent(e) doesn't work because class Task has changed (one field changed type from User to String)

 try{                   
        PersistenceManager pm = PMF.get().getPersistenceManager();  
        pm.flush();
        Query query = pm.newQuery(Task.class);
        query.declareParameters("String authorParam");
        List<Task> results = (List<Task>) query.execute("user@mail");
            try
            {
                 if (results.iterator().hasNext())
                 {
                    for (Task e : results) 
                    {
                      pm.deletePersistent(e);
                      %>
                      <p><%= e.getTask() %> </p>
                      <%
                    }
                 }else 
                     {
                       %> 
                       <p>Empty</p>
                       <% 
                     }
              } finally {
                query.closeAll();}
           pm.close();

       }catch(Exception ex) {...}

exception : java.lang.ClassCastException: java.lang.String cannot be cast to com.google.appengine.api.users.User

what shoud I do to clear all data from PersistenceManager?

plz help

+1  A: 

Hi!

  1. Did you try flush() before deleting?
  2. Did you try determine the e has class type that pm is storing?

Also, post here the full code please, or snippet as minimum.

Regards Eugene

Eugene
+1  A: 

please attach Task class. btw did you mind to use deletePersistentAll way instead of iterator?

Eugene
yes I done this before and it didn't work
qazah
A: 

Hi again qazah, would you mind to trace in from this line

if (results.iterator().hasNext())

and post here the content of results set.

Also you have truncated exception message, could you please post it in a full version?

Regards
Eugene

Eugene
I solve this in other way - I deleted manually all data from serwer when my application was - https://appengine.google.com/ Thanks for your attentionRegardsKrzysztof
qazah
congrats! it will be great for community if you'll put working code here too, with your hacks :)
Eugene