Problem deleting an object using PersistenceManager

I create a Data Class and save the data using PersistenceManager, but later I edited my data class and now I have a problem with the shared data I'm trying to delete these objects (pm.deletePersistent (e)), but I have an exception:

javax.jdo.JDOUserException: one or more instances cannot be deleted. NestedThrowables: org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: class "Class java.lang.Class" is not persistent. This means that it was either not improved, or that the extended version of the file is not in CLASSPATH (or hidden with an unsecured version), or metadata / annotations for the class were not found. "not saved.

what is 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;
    }

.jsp , deletePersistentAll (Task.class) pm.deletePersistent(e) , Task ( )

 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 com.google.appengine.api.users.User

, PersistenceManager?

plz

+3
1
  • flush() ?
    1. e , pm?

, , , .

+1

Source: https://habr.com/ru/post/1760276/


All Articles