title: Service layer with Data Transfer Objects (DTO)
body: <p>I'm working on a multi module maven based application based on the following modules:</p>
  <ol>
  <li>Model, contains all the Domain Entities</li>
  <li>Persistence, contains all the Repository (or DAO) used to access the models</li>
  <li>Service, contains all the business logic</li>
  <li>Web, contains all the controllers logic to expose rest API</li>
  </ol>
  <p>The problem I'm trying to figure out is about the DTO mapping, right now the dependency are organized in a linear way:</p>
  <pre><code>  Model &lt;- Persistence &lt;- Service &lt;- Web
  </code></pre>
  <p>Where all the DTO logic should belong? Let's say we have a method inside the <strong>service layer</strong> called</p>
  <pre><code>createRoom(CreateRoomDTO createRoomDTO)
  </code></pre>
  <p>in this case the <strong>CreateRoomDTO</strong> class is highly coupled with the service and web modules, but not all the DTO classes are used by the service layer (for example a PaginationFilter)</p>