Note that there are some explanatory texts on larger screens.

plurals
  1. POAppEngine Persist object delay?
    primarykey
    data
    text
    <p>My situation is as followed:<br> I have a list of Session in my table. <BR> In my code i do a check if the last Session in the datastore has room for an aditional player.<BR> If not create a new Session.</p> <p>It goes a little something like this:</p> <pre><code>public Session getEligeableSession(){ Session session; session = ds.getLastSession(); if(session.numPlayers &gt; 3){ newSession(); session = ds.getLastSession(); } return session; } </code></pre> <p>This works flawlessly on local but it doesn't on AppEngine's AppSpot.<br> On AppSpot i just get a filled up session back , i have to conclude from this that my code doesn't wait for the new session to get fully persisted and just get's the old session again.</p> <p>Is my conclusion right? if so how would i go about solving this graciously.<BR> Searching for this 'delay' has resulted in nothing on Google/SO which makes me believe there is no such a thing(aka it's synchronous) and there is a different fail in my code.(perhaps getting the last object from the list works differently on AppEngine)</p> <p>Any and all help/advice is much appreciated.</p> <p>Summary:</p> <p>Session(Object) has(List) 4 Players(Object) <BR> <B>getLastSession()</B> retrieves the whole list from the datastore and get the last one(<I>size-1</I>).<BR> <B>newSession()</B> creates a new Session object and persists it.</p> <p>EDIT per request:</p> <pre><code>public List&lt;Session&gt; getAll(){ pm = PMF.get().getPersistenceManager(); String query = "select from " + Session.class.getName(); @SuppressWarnings("unchecked") List&lt;Session&gt; sessions = (List&lt;Session&gt;) pm.newQuery(query).execute(); return sessions; } public Session getLastSession(){ List&lt;Session&gt; sessions = getAll(); Session session = sessions.get(sessions.size()-1); session.activeGame = session.numPlayers == 4 ? true : false; pm.close(); return session; } public int insert(Session session){ pm = PMF.get().getPersistenceManager(); int status = 0; try { pm.makePersistent(session); } finally { pm.close(); } return status; } </code></pre> <p>The code seems 'Reasonable', no funny stuff happening afaik. I'm using the master-slave option.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload