MYBATIS - Overview



MyBatis is an open source, lightweight, persistence framework. It is an alternative to JDBC and Hibernate. It automates the mapping between SQL databases and objects in Java, .NET, and Ruby on Rails. The mappings are decoupled from the application logic by packaging the SQL statements in XML configuration files.

It abstracts almost all of the JDBC code, and reduces the burden of setting of parameters manually and retrieving the results. It provides a simple API to interact with the database. It also provides support for custom SQL, stored procedures and advanced mappings.

It was formerly known as IBATIS, which was started by Clinton Begin in 2002. MyBatis 3 is the latest version. It is a total makeover of IBATIS.

A significant difference between MyBatis and other persistence frameworks is that MyBatis emphasizes the use of SQL, while other frameworks such as Hibernate typically uses a custom query language i.e. the Hibernate Query Language (HQL) or Enterprise JavaBeans Query Language (EJB QL).

MYBATIS Design Features

MyBatis comes with the following design philosophies −

  • Simplicity − MyBatis is widely regarded as one of the simplest persistence frameworks available today.

  • Fast Development − MyBatis does all it can to facilitate hyper-fast development.

  • Portability − MyBatis can be implemented for nearly any language or platform such as Java, Ruby, and C# for Microsoft .NET.

  • Independent Interfaces − MyBatis provides database-independent interfaces and APIs that help the rest of the application remain independent of any persistence-related resources.

  • Open source− MyBatis is free and an open source software.

Advantages of MYBATIS

MYBATIS offers the following advantages −

  • Supports stored procedures − MyBatis encapsulates SQL in the form of stored procedures so that business logic can be kept out of the database, and the application is more portable and easier to deploy and test.

  • Supports inline SQL − No pre-compiler is needed, and you can have the full access to all of the features of SQL.

  • Supports dynamic SQL − MyBatis provides features for dynamic building SQL queries based on parameters.

  • Supports O/RM − MyBatis supports many of the same features as an O/RM tool, such as lazy loading, join fetching, caching, runtime code generation, and inheritance.

MyBatis Advantages

MyBatis uses JAVA programming language while developing database oriented application. Before proceeding further, make sure that you understand the basics of procedural and object-oriented programming − control structures, data structures and variables, classes, objects, etc.

To understand JAVA in detail you can go through our JAVA Tutorial.

Advertisements