Example usage for org.apache.ibatis.binding MapperProxyFactory newInstance

List of usage examples for org.apache.ibatis.binding MapperProxyFactory newInstance

Introduction

In this page you can find the example usage for org.apache.ibatis.binding MapperProxyFactory newInstance.

Prototype

public T newInstance(SqlSession sqlSession) 

Source Link

Usage

From source file:com.baomidou.mybatisplus.MybatisMapperRegistry.java

License:Apache License

@SuppressWarnings("unchecked")
public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
    final MapperProxyFactory<T> mapperProxyFactory = (MapperProxyFactory<T>) knownMappers.get(type);
    if (mapperProxyFactory == null) {
        throw new BindingException("Type " + type + " is not known to the MybatisPlusMapperRegistry.");
    }//w ww .j  a  va2  s . c  o  m
    try {
        return mapperProxyFactory.newInstance(sqlSession);
    } catch (Exception e) {
        throw new BindingException("Error getting mapper instance. Cause: " + e, e);
    }
}