I am new to GAE, and JDO, I am fixated on how to update data.
Using the code below, if I do getAll() and then get() for an object, change the attribute for that object returned by get (), then a getAll() , the second call to getAll() returns the original unmodified object.
I tried to make flash (), but that doesn't seem to help. If I restart the pier, the data is not saved.
public class Notes { @SuppressWarnings("unchecked") public List<Note> getAll() { PersistenceManager pm = PMF.instance().getPersistenceManager(); Query query = pm.newQuery("select from com.uptecs.google1.model.Note order by subject"); return (List<Note>) query.execute(); } public void add(Note note) { PersistenceManager pm = PMF.instance().getPersistenceManager(); pm.makePersistent(note); pm.flush(); } public Note get(long id) { PersistenceManager pm = PMF.instance().getPersistenceManager(); return (Note)pm.getObjectById(Note.class, id); } public void update(Note note) { PersistenceManager pm = PMF.instance().getPersistenceManager(); pm.flush(); } }
Jacob source share