Local datastore not persisted between application

2019-07-22 03:21发布

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?

2条回答
时光不老,我们不散
2楼-- · 2019-07-22 03:52

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".

查看更多
霸刀☆藐视天下
3楼-- · 2019-07-22 03:55

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();
%>
查看更多
登录 后发表回答