title: Change Column Value After X Hours Using Hibernate
body: <p>I have an Enum called <code>TaskStatus</code> that can be either INCOMPLETE, QUEUE, ACTIVE, or COMPLETE. If the status is ACTIVE for longer than 12 hours, I want it to expire and return to INCOMPLETE.</p>
  <p>So far in my Task entity I have.</p>
  <pre class="lang-java prettyprint-override"><code>/**
   * Automatically updates status from ACTIVE to INCOMPLETE after 12 hours.
   * Note this method does not change data in the database. It only appears
   * as INCOMPLETE to the presentation layer.
   */
  @PostLoad
  public void updateStatus() {
      Date twelveHoursAgo = new Date(new Date().getTime() - TimeUnit.HOURS.toMillis(12));
      if( this.status == TaskStatus.ACTIVE &amp;&amp; this.lastUpdated.before(twelveHoursAgo)) {
          this.status = TaskStatus.INCOMPLETE;
      }
  }
  </code></pre>
  <p>I'm wanting a solution that will change the status in the database, not just in the Java object after it's mapped from the db.</p>