|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.mybatis.spring.support.SqlSessionDaoSupport
org.mybatis.spring.mapper.MapperFactoryBean<T>
public class MapperFactoryBean<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.
SqlSessionTemplate| Field Summary |
|---|
| Fields inherited from class org.springframework.dao.support.DaoSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
MapperFactoryBean()
|
|
| Method Summary | |
|---|---|
protected void |
checkDaoConfig()
|
T |
getObject()
|
Class<T> |
getObjectType()
|
boolean |
isSingleton()
|
void |
setAddToConfig(boolean addToConfig)
If addToConfig is false the mapper will not be added to MyBatis. |
void |
setMapperInterface(Class<T> mapperInterface)
Sets the mapper interface of the MyBatis mapper |
| Methods inherited from class org.mybatis.spring.support.SqlSessionDaoSupport |
|---|
getSqlSession, setSqlSessionFactory, setSqlSessionTemplate |
| Methods inherited from class org.springframework.dao.support.DaoSupport |
|---|
afterPropertiesSet, initDao |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MapperFactoryBean()
| Method Detail |
|---|
public void setMapperInterface(Class<T> mapperInterface)
mapperInterface - class of the interfacepublic 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 - protected void checkDaoConfig()
checkDaoConfig in class SqlSessionDaoSupport
public T getObject()
throws Exception
getObject in interface org.springframework.beans.factory.FactoryBean<T>Exceptionpublic Class<T> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<T>public boolean isSingleton()
isSingleton in interface org.springframework.beans.factory.FactoryBean<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||