Retrieve elements older than 5 minutes in DB
<p>I'm using play framework version 1.2.5 and I would like to retrieve all the connected users that didn't update their session for 5 minutes, and then I would like to set their connection status to "disconnected".</p>

<p>Here is my model :</p>

<pre><code>@Entity
public class User extends Model {

    @Required
    public String name;

    public boolean isConnected;

    public Date lastConnectionDate;

}
</code></pre>

<p>And here is the Job that update the users :</p>

<pre><code>Date fiveMinsAgo = new Date(new Date().getTime() - 5 * 60);
List&lt;User&gt; list = User.find("select u from User u where u.isConnected = true and u.lastConnectionDate &lt; ?", fiveMinsAgo).fetch();

for (User user : list) {
    // We set these accounts as disconnected
    user.isConnected = false;
    user.save();
}
</code></pre>

<p>This code does not seem to work. User are set to "disconnected" even if their <em>lastConnectionDate</em> is not older than 5 minutes ago.
Did I do something wrong ?</p>

<p>Is there a better way/code to do what I would like to do ? (like an UPDATE command)</p>

<p>Thank you for your help</p>
