开发者

Local datastore not persisted between application restarts

开发者 https://www.devze.com 2023-04-05 15:02 出处:网络
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 开发者_如何学JAVAdatastore

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 开发者_如何学JAVAdatastore

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?


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


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();
%>
0

精彩评论

暂无评论...
验证码 换一张
取 消