Class MapperFactoryBean<T>

java.lang.Object
org.springframework.dao.support.DaoSupport
org.mybatis.spring.support.SqlSessionDaoSupport
org.mybatis.spring.mapper.MapperFactoryBean<T>
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean

public class MapperFactoryBean<T> extends SqlSessionDaoSupport implements org.springframework.beans.factory.FactoryBean<T>
BeanFactory that enables injection of MyBatis mapper interfaces. It can be set up with a SqlSessionFactory or a pre-configured SqlSessionTemplate.

Sample configuration:

 
   <bean id="baseMapper" class="org.mybatis.spring.mapper.MapperFactoryBean" abstract="true" lazy-init="true">
     <property name="sqlSessionFactory" ref="sqlSessionFactory" />
   </bean>

   <bean id="oneMapper" parent="baseMapper">
     <property name="mapperInterface" value="my.package.MyMapperInterface" />
   </bean>

   <bean id="anotherMapper" parent="baseMapper">
     <property name="mapperInterface" value="my.package.MyAnotherMapperInterface" />
   </bean>
 
 

Note that this factory can only inject interfaces, not concrete classes.

Author:
Eduardo Macarron
See Also: