title: Play framework 2 multiple async db operation
body: <p>I am doing 2 db queries in my action.</p>
  
  <p>1, load an entity
  2, load information once the entity is loaded.</p>
  
  <p>I am trying this action async. I am not sure what is the best way to go about it.</p>
  
  <p>inside a MAP method would the rest of the code in the function treated as async or would that be executed by the calling thread ?</p>
  
  <p>e.g.</p>
  
  <pre><code>F.Promise&lt;Period&gt; period  = Period.asyncLoad(periodId);
  
      return period.map(new F.Function&lt;Period, Result&gt;() {
          @Override
          public Result apply(Period period) throws Throwable {
              if ( period == null ) {
                  String error = Messages.get("errors.notAvailable", Messages.get("entity.period"),periodId);
                  return notFound(helpers.Json.buildError( error ));
              } else {
                  Long id = countryId.isDefined() ? countryId.get():null;
                  **List&lt;EntitySummary&gt; counts = Notification.count(period, id );**
                  return ok(Json.toJson(counts));
              }
          }});
  }
  </code></pre>
  
  <p>As you can see there is a second call to db <strong>List counts = Notification.count(period, id );</strong></p>
  
  <p>what is the best way to do this ? Should I move this to the Model layer ?</p>