public class MapperFactoryBean<T>
extends org.mybatis.spring.support.SqlSessionDaoSupport
implements org.springframework.beans.factory.FactoryBean<T>
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.
SqlSessionTemplate
Constructor and Description |
---|
MapperFactoryBean() |
MapperFactoryBean(Class<T> mapperInterface) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkDaoConfig() |
Class<T> |
getMapperInterface()
Return the mapper interface of the MyBatis mapper
|
T |
getObject() |
Class<T> |
getObjectType() |
boolean |
isAddToConfig()
Return the flag for addition into MyBatis config.
|
boolean |
isSingleton() |
void |
setAddToConfig(boolean addToConfig)
If addToConfig is false the mapper will not be added to MyBatis.
|
void |
setMapperHelper(MapperHelper mapperHelper)
设置通用 Mapper 配置
|
void |
setMapperInterface(Class<T> mapperInterface)
Sets the mapper interface of the MyBatis mapper
|
protected void checkDaoConfig()
checkDaoConfig
in class org.mybatis.spring.support.SqlSessionDaoSupport
public Class<T> getMapperInterface()
public void setMapperInterface(Class<T> mapperInterface)
mapperInterface
- class of the interfacepublic Class<T> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<T>
public boolean isAddToConfig()
public void setAddToConfig(boolean addToConfig)
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
- public void setMapperHelper(MapperHelper mapperHelper)
mapperHelper
- public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<T>
Copyright © 2018. All rights reserved.