You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

MyBatis Exploration

We are exploring MyBatis as a faster, more flexible data access framework than Hibernate.

What is MyBatis?

MyBatis maps  Java objects to SQL result sets. This is different from Hibernate, which maps Java objects to RDBMS entities (tables or views). With MyBatis, you code SQL statements and map the result sets to Java POJOs. The quirks of the legacy MITSIS database are more readily handled by SQL than by Hibernate's object-relational model.

How Does MyBatis Work?

  1. You have a SQL statement that will return rows; each row will contain one or more columns. 
  2. You have Java POJOs designed to hold the data returned by the SQL query. 
  3. You have a mapping configuration that specifies how to move the SQL result set data into the Java POJOs.
  4. You have a mapper Java interface that provides the ability to actually run the query and populate the POJOs.

The Pieces

A sample project is available at <svn+ssh://svn.mit.edu/es-common-services-framework/sturner/mybatis-deptaudit-test>

This project uses MyBatis to retrieve the data involved in the Departmental Audit API. This involves getting a list of students who are in a particular department for a given term. For each student, various sets of data are retrieved. For this overview, we'll concentrate on the students and their courses. The simplified object model is:

 

Gliffy Macro Error

You do not have permission to view this diagram.

  • No labels