Package org.apache.ibatis.mapping

Examples of org.apache.ibatis.mapping.MappedStatement


    if (ivk.getTarget() instanceof RoutingStatementHandler) {
      RoutingStatementHandler statementHandler = (RoutingStatementHandler) ivk
          .getTarget();
      BaseStatementHandler delegate = (BaseStatementHandler) ReflectHelper
          .getValueByFieldName(statementHandler, "delegate");
      MappedStatement mappedStatement = (MappedStatement) ReflectHelper
          .getValueByFieldName(delegate, "mappedStatement");
      /**
       * 方法1:通过ID来区分是否需要分页..*query.*
       * 方法2:传入的参数是否有page参数,如果有,则分页,
       */
 
View Full Code Here


          fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
          resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty);

    id = assistant.applyCurrentNamespace(id);

    MappedStatement keyStatement = configuration.getMappedStatement(id, false);
    SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
    configuration.addKeyGenerator(id, answer);
    return answer;
  }
View Full Code Here

  void processIntercept(final Object[] queryArgs) {
    if(dialectClass!=null)
    {
      this.setDialect(dialectClass);
    }
    MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
    Object parameter = queryArgs[PARAMETER_INDEX];
    final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
    int offset = rowBounds.getOffset();
    int limit = rowBounds.getLimit();

    if (dialect.supportsLimit()
        && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
      BoundSql boundSql = ms.getBoundSql(parameter);
      String sql = boundSql.getSql().trim();
      if (dialect.supportsLimitOffset()) {
        sql = dialect.getLimitString(sql, offset, limit);
        offset = RowBounds.NO_ROW_OFFSET;
      } else {
        sql = dialect.getLimitString(sql, 0, limit);
      }
      limit = RowBounds.NO_ROW_LIMIT;

      queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
      BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql,
          boundSql.getParameterMappings(),
          boundSql.getParameterObject());
      MappedStatement newMs = copyFromMappedStatement(ms,
          new BoundSqlSqlSource(newBoundSql));
      queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
    }
  }
View Full Code Here

    builder.keyProperty(ms.getKeyProperty());
    builder.timeout(ms.getTimeout());
    builder.parameterMap(ms.getParameterMap());
    builder.resultMaps(ms.getResultMaps());
    builder.cache(ms.getCache());
    MappedStatement newMs = builder.build();
    return newMs;
  }
View Full Code Here

  protected void rebindGeneratedKey() {
    if (boundSql.getParameterObject() != null) {
      String keyStatementName = mappedStatement.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX;
      if (configuration.hasStatement(keyStatementName)) {
        MappedStatement keyStatement = configuration.getMappedStatement(keyStatementName);
        if (keyStatement != null) {
          String keyProperty = keyStatement.getKeyProperty();
          MetaObject metaParam = configuration.newMetaObject(boundSql.getParameterObject());
          if (keyProperty != null && metaParam.hasSetter(keyProperty) && metaParam.hasGetter(keyProperty)) {
            boundSql.setAdditionalParameter(keyProperty, metaParam.getValue(keyProperty));
          }
        }
View Full Code Here

      for (int i = 0, n = statementList.size(); i < n; i++) {
        Statement stmt = statementList.get(i);
        BatchResult batchResult = batchResultList.get(i);
        try {
          batchResult.setUpdateCounts(stmt.executeBatch());
          MappedStatement ms = batchResult.getMappedStatement();
          Object parameter = batchResult.getParameterObject();
          KeyGenerator keyGenerator = ms.getKeyGenerator();
          if (keyGenerator instanceof Jdbc3KeyGenerator) {
            keyGenerator.processAfter(this, ms, stmt, parameter);
          }
        } catch (BatchUpdateException e) {
          StringBuffer message = new StringBuffer();
View Full Code Here

    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

    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

  }

  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

    }
    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

TOP

Related Classes of org.apache.ibatis.mapping.MappedStatement

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.