List of usage examples for org.apache.ibatis.reflection ExceptionUtil unwrapThrowable
public static Throwable unwrapThrowable(Throwable wrapped)
From source file:com.fjn.helper.frameworkex.mybatis.plugin.PluginEnhancement.java
License:Apache License
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try {//from w w w .j av a 2 s .c o m Set<Method> methods = signatureMap.get(method.getDeclaringClass()); if (methods != null && methods.contains(method)) { return interceptor.intercept(new Invocation(target, method, args)); } return method.invoke(target, args); } catch (Exception e) { throw ExceptionUtil.unwrapThrowable(e); } }
From source file:com.ibatis.dao.engine.impl.DaoProxy.java
License:Apache License
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result = null;//from w ww . j a v a2 s . c o m if (PASSTHROUGH_METHODS.contains(method.getName())) { try { result = method.invoke(daoImpl.getDaoInstance(), args); } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } } else { StandardDaoManager daoManager = daoImpl.getDaoManager(); DaoContext context = daoImpl.getDaoContext(); if (daoManager.isExplicitTransaction()) { // Just start the transaction (explicit) try { context.startTransaction(); result = method.invoke(daoImpl.getDaoInstance(), args); } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } } else { // Start, commit and end the transaction (autocommit) try { context.startTransaction(); result = method.invoke(daoImpl.getDaoInstance(), args); context.commitTransaction(); } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } finally { context.endTransaction(); } } } return result; }