org.apache.ibatis.binding.MybatisCommonsMapperProxyFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-data-mybatis Show documentation
Show all versions of spring-data-mybatis Show documentation
使用spring-data-commons实现mybatis应用
The newest version!
package org.apache.ibatis.binding;
import java.lang.reflect.Method;
import java.util.Map;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.ibatis.binding.MapperProxy.MapperMethodInvoker;
import org.apache.ibatis.session.SqlSession;
/**
* @author 潜行的青衣
*/
public class MybatisCommonsMapperProxyFactory extends MapperProxyFactory {
/**
* @param mapperInterface
*/
public MybatisCommonsMapperProxyFactory(Class mapperInterface) {
super(mapperInterface);
}
@SuppressWarnings("unchecked")
@Override
public T newInstance(SqlSession sqlSession) {
Class mapperInterface = null;
Map methodCache = null;
try {
mapperInterface = (Class) FieldUtils.readField(this, "mapperInterface", true);
methodCache = (Map) FieldUtils.readField(this, "methodCache", true);
final MapperProxy mapperProxy = new MybatisCommonsMapperProxy(sqlSession, mapperInterface, methodCache);
return newInstance(mapperProxy);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
}