类 MapperFactoryBean<T>
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- org.mybatis.spring.support.SqlSessionDaoSupport
-
- tk.mybatis.spring.mapper.MapperFactoryBean<T>
-
- 所有已实现的接口:
org.springframework.beans.factory.FactoryBean<T>,org.springframework.beans.factory.InitializingBean
public class MapperFactoryBean<T> extends org.mybatis.spring.support.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> <p> <bean id="oneMapper" parent="baseMapper"> <property name="mapperInterface" value="my.package.MyMapperInterface" /> </bean> <p> <bean id="anotherMapper" parent="baseMapper"> <property name="mapperInterface" value="my.package.MyAnotherMapperInterface" /> </bean>Note that this factory can only inject interfaces, not concrete classes.
- 作者:
- Eduardo Macarron, liuzh
- 另请参阅:
SqlSessionTemplate
-
-
构造器概要
构造器 构造器 说明 MapperFactoryBean()MapperFactoryBean(Class<T> mapperInterface)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected voidcheckDaoConfig()Class<T>getMapperInterface()Return the mapper interface of the MyBatis mapperTgetObject()Class<T>getObjectType()booleanisAddToConfig()Return the flag for addition into MyBatis config.booleanisSingleton()voidsetAddToConfig(boolean addToConfig)If addToConfig is false the mapper will not be added to MyBatis.voidsetMapperHelper(tk.mybatis.mapper.mapperhelper.MapperHelper mapperHelper)设置通用 Mapper 配置voidsetMapperInterface(Class<T> mapperInterface)Sets the mapper interface of the MyBatis mapper
-
-
-
方法详细资料
-
checkDaoConfig
protected void checkDaoConfig()
- 覆盖:
checkDaoConfig在类中org.mybatis.spring.support.SqlSessionDaoSupport
-
getMapperInterface
public Class<T> getMapperInterface()
Return the mapper interface of the MyBatis mapper- 返回:
- class of the interface
-
setMapperInterface
public void setMapperInterface(Class<T> mapperInterface)
Sets the mapper interface of the MyBatis mapper- 参数:
mapperInterface- class of the interface
-
getObjectType
public Class<T> getObjectType()
- 指定者:
getObjectType在接口中org.springframework.beans.factory.FactoryBean<T>
-
isAddToConfig
public boolean isAddToConfig()
Return the flag for addition into MyBatis config.- 返回:
- true if the mapper will be added to MyBatis in the case it is not already registered.
-
setAddToConfig
public void setAddToConfig(boolean addToConfig)
If addToConfig is false the mapper will not be added to MyBatis. This means it must have been included in mybatis-config.xml. If it is true, the mapper will be added to MyBatis in the case it is not already registered. By default addToCofig is true.- 参数:
addToConfig-
-
setMapperHelper
public void setMapperHelper(tk.mybatis.mapper.mapperhelper.MapperHelper mapperHelper)
设置通用 Mapper 配置- 参数:
mapperHelper-
-
isSingleton
public boolean isSingleton()
- 指定者:
isSingleton在接口中org.springframework.beans.factory.FactoryBean<T>
-
-