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

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

Introduction

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

Prototype

public Object execute(SqlSession sqlSession, Object[] args) 

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;
    }/*from   w w w.j a  v a  2s.  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;
    }/*www .j  av a2  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;
}