title: Where should I implement specific queries in mvc architecture(spring + hibernate)?
body: <p>I'm implementing an enterprise application using spring mvc and hibernate. The application architecture is composed by the following layers:</p>
  
  <ul>
  <li>View</li>
  <li>Controller</li>
  <li>Service</li>
  <li>Domain</li>
  <li>Peristence</li>
  </ul>
  
  <p>The data access is implemented with classic dao pattern and allows CRUD operations + generic queries. Where should I implement specific queries? I guess two solutions:</p>
  
  <ul>
  <li>implement specific queries in the service layer by creating hibernate criteria and passing it to the persistence layer</li>
  <li>implement specific queries in DAO classes by create a function for each query and call the functions in the service layer.</li>
  </ul>
  
  <p>What should I do? Are there better solutions?</p>