title: How to design interfaces for complex query in DAO(Should we always design generic interfaces for DAO)?
body: <p>I was told to write generic interface for DAO When I first learning coding. It's not recommend to design a interface "findByName" and something like that, because findBy<strong>Name</strong> related with business logic( the name). I used Criteria of hibernate to write generic interfaces, it worked well. While I used mybatis recently, it's hard to keep the interfaces generic because I had to write sql myself. I write many methods like this:</p>
  
  <pre><code>T find(QueryTuple queryTuple);
  
  public class QueryTuple {
      private String key;
      private Object value;
      //This is an enum
      private CompareOperqator operator;
      // setter and getter
  }
  </code></pre>
  
  <p>And I invoked the find method like this:</p>
  
  <pre><code>find(new QueryTuple("name", "tom", CompareOperqator.EQUAL));
  find(new QueryTuple("gender", "m", CompareOperqator.EQUAL));
  </code></pre>
  
  <p>However if I want to write some complex queries, I can not keep the interface so "generic", I have to write interface such as findByXXAndXX.</p>
  
  <p>Is it really good to keep so called "generic"? I found Spring data also support interface like findByXX.</p>