MyBatis-Spring 1.0.0-SNAPSHOT - Reference ... - Google Groups

6 downloads 158 Views 20KB Size Report
Every Spring user was impatiently waiting for the 3.X release, but unfortunately once released, MyBatis users where terr
MyBatis-Spring 1.0.0-SNAPSHOT - Reference Documentation

The MyBatis Community (MyBatis.org)

Copyright © 2010

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.

1. Introduction .................................................................................................................................. 1 1.1. Why mybatis-spring - Motivation ........................................................................................ 1 1.2. Requirements ..................................................................................................................... 1 1.3. Acknowledgements ............................................................................................................ 1 2. Bootstrap ...................................................................................................................................... 2 2.1. Introduction ....................................................................................................................... 2 2.2. Setting up a SqlSessionFactory ........................................................................................... 2 3. Using SqlSessionDaoTemplate and SqlSessionDaoSupport ............................................................. 3 3.1. SqlSessionDaoSupport ....................................................................................................... 3 3.2. .......................................................................................................................................... 3 4. Injecting Mappers ......................................................................................................................... 4 4.1. Injecting Mappers .............................................................................................................. 4 5. Using MyBatis API ....................................................................................................................... 5 5.1. Using MyBatis API ............................................................................................................ 5

ii

Chapter 1. Introduction 1.1. Why mybatis-spring - Motivation Every Spring user was impatiently waiting for the 3.X release, but unfortunately once released, MyBatis users where terribly disappointed: their preferred SQL Mapping Framework was no more supported. After many request of including the integration and a good number of patches submitted on the Spring Jira issue, once the issue was accepted but announced to be delaiyed, the MyBatis community thought it was time to reunite the interested people and contributors and start the Spring integration made by the community itself. So, this small library intends to create the missing perfect glue between the two popular frameworks, reducing the boilerplate and redundant code that users have to write to configure and use MyBatis into a Spring 3.X context.

1.2. Requirements Before starting reading the manual, it is very important you're familiar with both MyBatis and Spring framework and therminology, otherwise it would be very difficult to understand the described context. Like MyBatis, mybatis-spring requires Java 5 or higher.

1.3. Acknowledgements A special thanks goes to all the special people who made this project a reality, above all (in alphabetical order) Andrius Juozapaitis, Eduardo Macarron, Giovanni Cuccu, Hunter Presnall, Putthibong Boonbong and Raj Nagappan. Without them, that project wouldn't exist.

1

Chapter 2. Bootstrap 2.1. Introduction MyBatis-Spring integration helps you to integrate your code seamlessly with Spring. Spring will load and create necessary MyBatis classes for you. It will also inject working Mappers/Daos directly on your service beans.

2.2. Setting up a SqlSessionFactory As you already know, to use MyBatis you need to build a SqlSessionFactory from XML files. MyBatis-Spring will build a SqlSessionFactory for you during Spring startup. The XML snippet below shows the configuration needed to build a SqlSessionFactoryBean:

Suggest Documents