Local datastore not persisted between application restarts

风格不统一 提交于 2019-12-11 02:49:26

问题


I am running the GuestBook example from Google Developer CodeLab.

When adding an entry, it shows up in the list of greetings and in the local datastore

So far so good...

When I restart the application, however, only some of the entries still exist, while some disappear entirely, both from the list maintained by my app, and from the local datastore, as seen in above link.

I am using the google plugin for Eclipse to develop and test my application.

Can anyone point me in the right direction?


回答1:


It's likely you're passing the --clear-datastore argument, either directly or through the launcher, to the dev_appserver. Another possibility is that something is erasing your temporary directory (such as on reboot), which is the default location for the dev_appserver's local datastore.

I don't know what would cause only some entities to disappear, and it's impossible to say without seeing your code. I also don't know what you mean by "the list maintained by [your] app".




回答2:


Thank you for your answer.

I would think that a --clear-datastore argument, would erase ALL values, not just some.

The local datastore files, in the appengine-generated folder, are still there when I restart, and again, I would think that all values would disappear, if these files were erased.

The code is unmodified from the google codelab example (link provided in question). The list maintained by my app, is just the list returned by the query and printed out:

<%
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + Greeting.class.getName();
    List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute();
    if (greetings.isEmpty()) {
%>
<p>The guestbook has no messages.</p>
<%
    } else {
        for (Greetingg : greetings) {
            if (g.getAuthor() == null) {
%>
<p>An anonymous person wrote:</p>
<%
            } else {
%>
<p><b><%= g.getAuthor().getNickname() %></b> wrote:</p>
<%
            }
%>
<blockquote><%= g.getContent() %></blockquote>
<%
        }
    }
    pm.close();
%>


来源:https://stackoverflow.com/questions/7430888/local-datastore-not-persisted-between-application-restarts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!