Category Archives: java

MyBatis Tutorial (A Quick Start Guide)

This brief MyBatis tutorial explains and demonstrates the basics of MyBatis (formerly ibatis).

This tutorial uses MyBatis Version 3.  It will walk you through the four major components you’ll need to have in place to get started:

  • a configuration file — this general configuration holds things like the name of the database, userid and password as well as some other configuration options.
  • java classes that will represent the database tables (models)
  • a mybatis xml file which is called a mapper.  The mapper xml file will contain your queries and an explicit map so the query results know which java class to use.
  • java class which will act as the interface to the xml mapper file