title: Hibernate: CRUD Generic DAO
body: <p>My web application has got a lot of service tables/entities, such as <code>payment_methods</code>, <code>tax_codes</code>, <code>province_codes</code>, etc.</p>
  <p>Each time I add a new entity, I have to write a DAO. The thing is that, basically, they are all the same, but the only difference is the <strong>entity class itself</strong>.</p>
  <p>I know that Hibernate tools can generate the code for me automatically but I can't use them now (don't ask why) so I'm thinking of a <strong>Generic DAO</strong>. There's a lot of literature about that but I can't put pieces together and make it work with Spring.</p>
  <p>It's all about generics I think, it will have four basic methods:</p>
  <ul>
  <li><code>listAll</code></li>
  <li><code>saveOrUpdate</code></li>
  <li><code>deleteById</code></li>
  <li><code>getById</code></li>
  </ul>
  <p>and that's all.</p>
  <hr>
  <h3>Question:</h3>
  <p>What's the <em>best practice</em> for not re-inventing the wheel? Isn't there something ready to use, yet?</p>