title: DAO design pattern
body: <p>So lets say we have a couple of entities we want to persist using DAO objects. So we implement the right interface so we end up with </p>
  
  <pre><code>class JdbcUserDao implements UserDao{
  //...
  }
  
  class JdbcAddressDao implements AddressDao{
  //...
  }
  </code></pre>
  
  <p>So if I want to be able to switch persistance implementations from JDBC to JPA (for example) and vice versa, I'd need to have JPAUserDao and JPAAddressDao... Meaning if I had 20 entities, and decided to switch implementations(using DI container), I'd have to switch every Jdbc implementation with JPA in code.</p>
  
  <p>Now it could be that I misunderstood how DAO works, but... If I just had </p>
  
  <pre><code>class JdbcDaoImpl implements UserDao,AddressDao{
  //...
  }
  </code></pre>
  
  <p>I'd then have all the JDBC implementations in one class, and switching implementations would be a piece of cake. Also, DaoImpl count is equal to number of Dao interfaces. Why not just group them by implementation (jdbc, JTA, JPA...) and have everything under one class?</p>
  
  <p>Thanks in advance.</p>