Example usage for org.apache.ibatis.binding MapperMethod MapperMethod

List of usage examples for org.apache.ibatis.binding MapperMethod MapperMethod

Introduction

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

Prototype

public MapperMethod(Class<?> mapperInterface, Method method, Configuration config) 

Source Link

Usage

From source file:com.eryansky.common.orm.mybatis.proxy.PaginationMapperProxy.java

License:Apache License

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (isObjectMethod(method)) {
        return null;
    }/* ww  w . j a  v  a  2 s  .c o  m*/
    final Class<?> declaringInterface = findDeclaringInterface(proxy, method);
    if (Page.class.isAssignableFrom(method.getReturnType())) {
        // ?
        return new PaginationMapperMethod(declaringInterface, method, sqlSession).execute(args);
    }
    // ??
    final MapperMethod mapperMethod = new MapperMethod(declaringInterface, method,
            sqlSession.getConfiguration());
    final Object result = mapperMethod.execute(sqlSession, args);
    if (result == null && method.getReturnType().isPrimitive()) {
        throw new BindingException("Mapper method '" + method.getName() + "' (" + method.getDeclaringClass()
                + ") attempted to return null from a method with a primitive return type ("
                + method.getReturnType() + ").");
    }
    return result;
}

From source file:com.lushapp.common.orm.mybatis.proxy.PaginationMapperProxy.java

License:Apache License

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (isObjectMethod(method)) {
        return null;
    }/*from  w  w  w  .ja  v a2s  . c o m*/
    final Class<?> declaringInterface = findDeclaringInterface(proxy, method);
    if (Page.class.isAssignableFrom(method.getReturnType())) {
        // ?
        return new PaginationMapperMethod(declaringInterface, method, sqlSession).execute(args);
    }
    // ??
    final MapperMethod mapperMethod = new MapperMethod(declaringInterface, method,
            sqlSession.getConfiguration());
    final Object result = mapperMethod.execute(sqlSession, args);
    if (result == null && method.getReturnType().isPrimitive()) {
        throw new BindingException("Mapper method '" + method.getName() + "' (" + method.getDeclaringClass()
                + ") attempted to return null from a method with a primitive return type ("
                + method.getReturnType() + ").");
    }
    return result;
}