What benefits MyBatis provides over working with plain JDBC

Gili Nachum picture Gili Nachum · Apr 24, 2012 · Viewed 7.6k times · Source

I need to write pretty straight forward DB code and I'm considering MyBatis over plain JDBC (I believe full ORM is an overkill).

Considering that in both MyBatis and plain JDBC you find yourself:

  1. Hand writing SQL statements.
  2. Manually wiring DB rows to JAVA DTO objects (either via code or config).

The MyBatis benefits over JDBC I know of are:

  1. Out-of-the-box table/query caching.
  2. Dynamic SQL.
  3. SQL is stored outside of the code.
  4. Templating SQL for easier DB vendor Independence.

What other MyBatis-Over-JDBC benefits are there to consider?

Answer

Anuj Patel picture Anuj Patel · Jun 9, 2012

I dont know you'll count this one as advantage or not but there's MyBatisGenerator, And It generates all basic needed Queries plus some Advanced Queries too and DTO objects automatically based on a single XML file.

Plus it has Eclipse Plugin For the same.