title: DTOs in Service layer - REST API
body: <p>I'm building a REST API service based on Jersey &amp; Hibernate which contains the following layers:
  <a href="http://i.stack.imgur.com/i9zM5.png" rel="nofollow">Architecture</a></p>
  
  <p>Each entity in the model has its own service in the service layer (interfaces).
  As described above, DTOs are passed to and from the service layer to the endpoints layer.
  The following is PolicySetService interface:</p>
  
  <pre><code>public interface PolicySetService extends BaseService&lt;PolicySet, PolicySetDao&gt; {
      String createPolicySet(String accountId, PolicySetDto policySet) throws PolicyException;
      void updatePolicySet(String accountId, String policySetId, PolicySetDto newPolicySet) throws PolicyException;
      PolicySetDto getPolicySetDto(String accountId, String policySetId) throws PolicyException;
      void deletePolicySet(String accountId, String policySetId) throws PolicyException;
  }
  </code></pre>
  
  <p>Now lets take a look at EvaluationService interface:</p>
  
  <pre><code>public interface EvaluationService extends BaseService&lt;Evaluation, EvaluationDao&gt; {
      EvaluationDto createEvaluation(String accountId, String policySetId, EvaluationRequestData requestData) throws PolicyException;
  }
  </code></pre>
  
  <p>I have been reading that its a best practice for one service (lets say EvaluationService) to call another (lets say PolicySetService) in order to get domain model entity for instance (Instead of calling directly to PolicySet Dao from EvaluationService)
  In my case, EvaluationService implementation should use PolicySetService to get PolicySet entity (not the DTO) to perform some business logic before the Evaluation Entity is being persisted.
  Currently, the PolicySetService returns DTO and i need to convert it to the real PolicySet entity in the EvaluationService.
  Note that the services should expose only DTOs to higher layers (but i need some how to expose the entity domain model inside the service layer, meaning between services)
  What is the best architecture to get this?
  Should i create another "internal" service interface for services to communicate with each other?
  Is there any better architecture for this?</p>