Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.Configuration


    super(transaction);
  }

  public int doUpdate(MappedStatement ms, Object parameter)
      throws SQLException {
    Configuration configuration = ms.getConfiguration();
    StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, RowBounds.DEFAULT, null);
    Statement stmt = prepareStatement(handler);
    return handler.update(stmt);
  }
View Full Code Here


    Statement stmt = prepareStatement(handler);
    return handler.update(stmt);
  }

  public List doQuery(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler) throws SQLException {
    Configuration configuration = ms.getConfiguration();
    StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, rowBounds, resultHandler);
    Statement stmt = prepareStatement(handler);
    return handler.query(stmt, resultHandler);
  }
View Full Code Here

    super(transaction);
  }

  public int doUpdate(MappedStatement ms, Object parameter)
      throws SQLException {
    Configuration configuration = ms.getConfiguration();
    StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, RowBounds.DEFAULT, null);
    Statement stmt = prepareStatement(handler);
    return handler.update(stmt);
  }
View Full Code Here

    Statement stmt = prepareStatement(handler);
    return handler.update(stmt);
  }

  public List doQuery(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler) throws SQLException {
    Configuration configuration = ms.getConfiguration();
    StatementHandler handler = configuration.newStatementHandler(this, ms, parameter, rowBounds, resultHandler);
    Statement stmt = prepareStatement(handler);
    return handler.query(stmt, resultHandler);
  }
View Full Code Here

  public XMLConfigBuilder(Reader reader, String environment) {
    this(reader, environment, null);
  }

  public XMLConfigBuilder(Reader reader, String environment, Properties props) {
    super(new Configuration());
    ErrorContext.instance().resource("SQL Mapper Configuration");
    this.configuration.setVariables(props);
    this.parsed = false;
    this.environment = environment;
    this.parser = new XPathParser(reader, true, new XMLMapperEntityResolver(), props);
View Full Code Here

    }

    private void resolveTypeHandler() {
      if (parameterMapping.typeHandler == null) {
        if (parameterMapping.javaType != null) {
          Configuration configuration = parameterMapping.configuration;
          TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
          parameterMapping.typeHandler = typeHandlerRegistry.getTypeHandler(parameterMapping.javaType, parameterMapping.jdbcType);
        }
      }
    }
View Full Code Here

    }
    return null;
  }

  private void parseStatement(Method method) {
    Configuration configuration = assistant.getConfiguration();
    SqlSource sqlSource = getSqlSourceFromAnnotations(method);
    if (sqlSource != null) {
      Options options = method.getAnnotation(Options.class);
      final String mappedStatementId = type.getName() + "." + method.getName();
      boolean flushCache = false;
      boolean useCache = true;
      Integer fetchSize = null;
      Integer timeout = null;
      StatementType statementType = StatementType.PREPARED;
      ResultSetType resultSetType = ResultSetType.FORWARD_ONLY;
      SqlCommandType sqlCommandType = getSqlCommandType(method);
      KeyGenerator keyGenerator = configuration.isUseGeneratedKeys()
          && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
      String keyProperty = "id";
      if (options != null) {
        flushCache = options.flushCache();
        useCache = options.useCache();
View Full Code Here

  public SqlSessionFactory getObject() throws Exception {
    final Reader reader = new InputStreamReader(this.configLocation.getInputStream());
    // Null environment causes the configuration to use the default.
    // This will be overwritten below regardless.
    final XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader, null, null);
    final Configuration configuration = xmlConfigBuilder.parse();

    final TransactionFactory transactionFactory = this.transactionFactoryClass.newInstance();

    final Environment env = new Environment(this.environment, transactionFactory, this.dataSource);
    configuration.setEnvironment(env);

    final SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    return builder.build(configuration);
  }
View Full Code Here

  public void processBefore(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
  }

  public void processAfter(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
    try {
      final Configuration configuration = ms.getConfiguration();
      final TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
      if (parameter != null) {
        String keyProperty = ms.getKeyProperty();
        final MetaObject metaParam = configuration.newMetaObject(parameter);
        if (keyProperty != null && metaParam.hasSetter(keyProperty)) {
          Class<?> keyPropertyType = metaParam.getSetterType(keyProperty);
          TypeHandler th = typeHandlerRegistry.getTypeHandler(keyPropertyType);
          if (th != null) {
            ResultSet rs = stmt.getGeneratedKeys();
View Full Code Here

  public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
    this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
  }
 
  private XMLConfigBuilder(XPathParser parser, String environment, Properties props) {
    super(new Configuration());
    ErrorContext.instance().resource("SQL Mapper Configuration");
    this.configuration.setVariables(props);
    this.parsed = false;
    this.environment = environment;
    this.parser = parser;
View Full Code Here

TOP

Related Classes of org.apache.ibatis.session.Configuration

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.