Example usage for org.apache.ibatis.exceptions ExceptionFactory wrapException

List of usage examples for org.apache.ibatis.exceptions ExceptionFactory wrapException

Introduction

In this page you can find the example usage for org.apache.ibatis.exceptions ExceptionFactory wrapException.

Prototype

public static RuntimeException wrapException(String message, Exception e) 

Source Link

Usage

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

License:Apache License

@Override
public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {/*from  w w w. j  a va 2  s.  c  o  m*/
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(reader, environment, properties);
        GlobalConfiguration.setGlobalConfig(parser.getConfiguration(), this.globalConfig);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        IOUtils.closeQuietly(reader);
    }
}

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

License:Apache License

@Override
public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {//from   w ww  . j  a v a  2 s  .c  o m
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(inputStream, environment, properties);
        GlobalConfiguration.setGlobalConfig(parser.getConfiguration(), this.globalConfig);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        IOUtils.closeQuietly(inputStream);
    }
}

From source file:com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor.java

License:Apache License

@Override
public void setProperties(Properties properties) {
    String versionHandlers = properties.getProperty("versionHandlers");
    if (StringUtils.isNotEmpty(versionHandlers)) {
        for (String handlerClazz : versionHandlers.split(",")) {
            try {
                registerHandler(Class.forName(handlerClazz));
            } catch (Exception e) {
                throw ExceptionFactory.wrapException("????", e);
            }//w  w w .  ja  va 2s .c  o  m
        }
    }
}

From source file:com.cetiti.dsp.builder.SqlSessionFactoryBuilder.java

License:Apache License

public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {//  www.  j  a  v  a 2  s  .c  o  m
        XMLServiceBuilder parser = new XMLServiceBuilder(reader, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        try {
            reader.close();
        } catch (IOException e) {
            // Intentionally ignore. Prefer previous error.
        }
    }
}

From source file:com.cetiti.dsp.builder.SqlSessionFactoryBuilder.java

License:Apache License

public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {/*from   ww w. j av a2s . co m*/
        XMLServiceBuilder parser = new XMLServiceBuilder(inputStream, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        try {
            inputStream.close();
        } catch (IOException e) {
            // Intentionally ignore. Prefer previous error.
        }
    }
}

From source file:com.mybatisX.core.MybatisSessionFactoryBuilder.java

License:Apache License

@Override
public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {/*from  ww w  .  j av  a2s  .  c  o m*/
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(reader, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        IOUtils.closeQuietly(reader);
    }
}

From source file:com.mybatisX.core.MybatisSessionFactoryBuilder.java

License:Apache License

@Override
public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {//from ww w.  j a v  a2  s .  c  o m
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(inputStream, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        IOUtils.closeQuietly(inputStream);
    }
}

From source file:com.raycloud.cobarclient.mybatis.spring.SqlSessionUtils.java

License:Apache License

/**
 * Environment?/*from w  w w. j a v a  2s. c  o  m*/
 *
 * @param environment
 * @param sessionFactory
 * @param executorType
 * @return
 */
private static SqlSession openSession(Environment environment, SqlSessionFactory sessionFactory,
        ExecutorType executorType) {
    Transaction tx = null;
    try {
        final TransactionFactory transactionFactory = environment.getTransactionFactory();
        tx = transactionFactory.newTransaction(environment.getDataSource(), null, false);
        final Executor executor = sessionFactory.getConfiguration().newExecutor(tx, executorType);
        return new DefaultSqlSession(sessionFactory.getConfiguration(), executor, false);
    } catch (Exception e) {
        closeTransaction(tx); // may have fetched a connection so lets call close()
        throw ExceptionFactory.wrapException("Error opening session.  Cause: " + e, e);
    } finally {
        ErrorContext.instance().reset();
    }
}

From source file:com.tj.mybatisplus.MybatisSessionFactoryBuilder.java

License:Apache License

@Override
public SqlSessionFactory build(Reader reader, String environment, Properties properties) {
    try {// www .j  a v a 2s.  co m
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(reader, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        try {
            reader.close();
        } catch (IOException e) {
            // Intentionally ignore. Prefer previous error.
        }
    }
}

From source file:com.tj.mybatisplus.MybatisSessionFactoryBuilder.java

License:Apache License

@Override
public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) {
    try {/*from  w ww.ja  va  2 s . c  o m*/
        MybatisXMLConfigBuilder parser = new MybatisXMLConfigBuilder(inputStream, environment, properties);
        return build(parser.parse());
    } catch (Exception e) {
        throw ExceptionFactory.wrapException("Error building SqlSession.", e);
    } finally {
        ErrorContext.instance().reset();
        try {
            inputStream.close();
        } catch (IOException e) {
            // Intentionally ignore. Prefer previous error.
        }
    }
}