Examples of MappedStatement


Examples of org.apache.ibatis.mapping.MappedStatement

    }
    return paramName;
  }

  private void setupCommandType() {
    MappedStatement ms = config.getMappedStatement(commandName);
    type = ms.getSqlCommandType();
    if (type == SqlCommandType.UNKNOWN) {
      throw new BindingException("Unknown execution method for: " + commandName);
    }
  }
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

    return selectList(statement, parameter, RowBounds.DEFAULT);
  }

  public List selectList(String statement, Object parameter, RowBounds rowBounds) {
    try {
      MappedStatement ms = configuration.getMappedStatement(statement);
      return executor.query(ms, wrapCollection(parameter), rowBounds, Executor.NO_RESULT_HANDLER);
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

    select(statement, parameter, RowBounds.DEFAULT, handler);
  }

  public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
    try {
      MappedStatement ms = configuration.getMappedStatement(statement);
      executor.query(ms, wrapCollection(parameter), rowBounds, handler);
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error querying database.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

  }

  public int update(String statement, Object parameter) {
    try {
      dirty = true;
      MappedStatement ms = configuration.getMappedStatement(statement);
      return executor.update(ms, wrapCollection(parameter));
    } catch (Exception e) {
      throw ExceptionFactory.wrapException("Error updating database.  Cause: " + e, e);
    } finally {
      ErrorContext.instance().reset();
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

  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

Examples of org.apache.ibatis.mapping.MappedStatement

  }

  public Object queryForObject(String id, Object parameterObject, Object userObject) throws SQLException {
    Object systemObject = queryForObject(id, parameterObject);
    if (systemObject != null && userObject != null) {
      MappedStatement ms = configuration.getMappedStatement(id);
      for (ResultMap rm : ms.getResultMaps()) {
        for (ResultMapping mapping : rm.getPropertyResultMappings()) {
          MetaObject metaUserObject = MetaObject.forObject(userObject);
          MetaObject metaSystemObject = MetaObject.forObject(systemObject);
          String propName = mapping.getProperty();
          if (propName != null) {
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

  }

  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) {
View Full Code Here

Examples of org.apache.ibatis.mapping.MappedStatement

  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

Examples of org.apache.ibatis.mapping.MappedStatement

  }

  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

Examples of org.apache.ibatis.mapping.MappedStatement

  }

  private int getKey(String id, final Object parameterObject) throws SQLException {
    int key = Integer.MIN_VALUE;
    String selectKeyId = selectKeyIdFor(id);
    final MappedStatement keyStatement;

    if (configuration.getMappedStatementNames().contains(selectKeyId)) {
      keyStatement = configuration.getMappedStatement(selectKeyId);
    } else {
      keyStatement = null;
    }
    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) {
        //Ignore...sometimes code sucks.  This is a good example.
      }
    }
    try {
      String property = keyStatement.getResultMaps().get(0).getResultMappings().get(0).getProperty();
      MetaObject.forObject(parameterObject).setValue(property, key);
    } catch (Exception e) {
      //Ignore...sometimes code sucks.  This is a good example.
    }
    return key;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.