Package org.apache.ibatis.executor

Examples of org.apache.ibatis.executor.Executor


      }
      connection = wrapConnection(connection);
      final Environment environment = configuration.getEnvironment();
      final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);
      Transaction tx = transactionFactory.newTransaction(connection, autoCommit);
      Executor executor = configuration.newExecutor(tx, execType);
      return new DefaultSqlSession(configuration, executor, autoCommit);
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error opening session.  Cause: " + e, e);
    }
  }
View Full Code Here


      if (level != null) {
        connection.setTransactionIsolation(level.getLevel());
      }
      connection = wrapConnection(connection);
      Transaction tx = transactionFactory.newTransaction(connection, autoCommit);
      Executor executor = configuration.newExecutor(tx, execType);
      return new DefaultSqlSession(configuration, executor, autoCommit);
    } catch (SQLException e) {
      throw ExceptionFactory.wrapException("Error opening session.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
View Full Code Here

      }
      connection = wrapConnection(connection);
      final Environment environment = configuration.getEnvironment();
      final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);
      Transaction tx = transactionFactory.newTransaction(connection, autoCommit);
      Executor executor = configuration.newExecutor(tx, execType);
      return new DefaultSqlSession(configuration, executor, autoCommit);
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error opening session.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
View Full Code Here

    }
    return resultObject;
  }

  private List selectList() throws SQLException {
    Executor localExecutor = executor;
    if (localExecutor.isClosed()) {
      localExecutor = newExecutor();
    }
    try {
      return localExecutor.query(mappedStatement, parameterObject, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
    } finally {
      if (localExecutor != executor) {
        localExecutor.close(false);
      }
    }
  }
View Full Code Here

  public int update(final String id, final Object parameterObject) throws SQLException {
    return (Integer) transactionManager.doInTransaction(new TransactionScope() {
      public Object execute(Transaction transaction) throws SQLException {
        transaction.setCommitRequired(true);
        MappedStatement ms = configuration.getMappedStatement(id);
        Executor executor = transaction.getExecutor();
        return executor.update(ms, wrapCollection(parameterObject));
      }
    });
  }
View Full Code Here

  public Object queryForObject(final String id, final Object parameterObject) throws SQLException {
    return transactionManager.doInTransaction(new TransactionScope() {
      public Object execute(Transaction transaction) throws SQLException {
        MappedStatement ms = configuration.getMappedStatement(id);
        Executor executor = transaction.getExecutor();
        List list = executor.query(ms, wrapCollection(parameterObject), RowBounds.DEFAULT, null);
        if (list.size() == 1) {
          return list.get(0);
        } else if (list.size() > 1) {
          throw new SQLException("queryForObject() returned more than one row.");
        } else {
View Full Code Here

  }

  public List queryForList(final String id, final Object parameterObject, final int skip, final int max) throws SQLException {
    return (List) transactionManager.doInTransaction(new TransactionScope() {
      public Object execute(Transaction transaction) throws SQLException {
        Executor executor = transaction.getExecutor();
        MappedStatement ms = configuration.getMappedStatement(id);
        return executor.query(ms, wrapCollection(parameterObject), new RowBounds(skip, max), null);
      }
    });
  }
View Full Code Here

  public void queryWithRowHandler(final String id, final Object parameterObject, final RowHandler rowHandler) throws SQLException {
    transactionManager.doInTransaction(new TransactionScope() {
      public Object execute(Transaction transaction) throws SQLException {
        MappedStatement ms = configuration.getMappedStatement(id);
        Executor executor = transaction.getExecutor();
        return executor.query(ms, wrapCollection(parameterObject), RowBounds.DEFAULT, new ResultHandler() {
          public void handleResult(ResultContext context) {
            rowHandler.handleRow(context.getResultObject());
          }
        });
      }
View Full Code Here

    }
    if (keyStatement != null) {
      List results = (List) transactionManager.doInTransaction(new TransactionScope() {
        public Object execute(Transaction transaction) throws SQLException {
          transaction.setCommitRequired(true);
          Executor executor = transaction.getExecutor();
          return executor.query(keyStatement, parameterObject, RowBounds.DEFAULT, null);
        }
      });
      try {
        key = (Integer) ((Map) results.get(0)).values().iterator().next();
      } catch (Exception e) {
View Full Code Here

    }
    return resultObject;
  }

  private List selectList() throws SQLException {
    Executor localExecutor = executor;
    if (localExecutor.isClosed()) {
      localExecutor = newExecutor();
    }
    try {
      return localExecutor.query(mappedStatement, parameterObject, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
    } finally {
      if (localExecutor != executor) {
        localExecutor.close(false);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.ibatis.executor.Executor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.