My aim is to persist a String to Datastore
final static PersistenceManager pm = PMF.get().getPersistenceManager();
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
String s = "test";
System.out.println(pm.makePersistent(s));
PrintWriter pw = resp.getWriter();
pw.write("Data Saved");
}
Not sure about the reason for following ERROR
The class “The class “java.lang.String” 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. 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 for the class is
not found.Caused by:
org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException:
The class “The class “java.lang.String” 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. 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 for the class is
not found. at
org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:241)
at
org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:674)
at
org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694)
at com.arunraja101.SaveDataServlet.doGet(SaveDataServlet.java:91)
Is an String Object can’t be persisted ?
You can persist a String in the datastore, but as part of an entity. You describe the entities that are written to and read from the datastore by defining a class. For instance, this document describes how to define an entity class using JDO.
The class dictates which fields are stored when the entities are written to the datastore, and where they are written. Without such a class, App Engine will not know where to save the data when you call
makePersistent(as is the case in your example code) nor how to read it back.