Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In this section, we discuss how to perform various CRUD operations with MyBatis in Spring.
For querying data, we will discuss how to perform mappings from SQL to POJOs, as well as model the relationships between domain objects. Moreover, topics including named parameters and dynamic SQL support in MyBatis will also be covered.
Finally, we will also discuss how to use MyBatis to implement insert/update/delete operations.
MyBatis provides intensive support for querying data in a database. Basically, for each select operation, we will define the SQL statement, the parameters, the result type (Java type), and the result mapping to use. Various relationships (one-to-one, one-to-many, and many-to-many) can be mapped easily. Another powerful feature in MyBatis is the support of dynamic SQL, which we will discuss in the following sections.