This article introduces mybatis java (iBatis 3 for java) and summarizes its configuration and usage. The article also give suggestions on its usage.



The iBATIS Data Mapper (born in 2002) is a framework that  introduces SQL Mapping approach to persistence layer development. The iBATIS name and code was donated to the Apache Software Foundation; that hosted project development for many years.

In 2010 the core development team of iBATIS has decided to continue development under the Google Code umbrella; then they switched to a new name: mybatis .

Actually mybatis is available both for Java and for .NET platform. Both the project teams forked their software to Google Code, on  mybatis Java and mybatis .NET . One of the best additions to the new version of the project it is the support for metadata annotations.

myBatis Configuration

building SqlSessionFactory from XML is quite simple:

The configuration file contains settings for the core of the MyBatis system



  • ${parameterName} : indicate a parameter, usually taken via propery file ..
  • mapper: imply the existence of the BlogMapper.xml file

myBatis Generator

For java guys it is also possible to generate XML files using the  myBatis artifacts generator,  available as standalone JAR; Ant task; Maven plugin or Eclipse plugin. See description on:, where you can get the JAR, and the Update Site for the Eclipse plugin.