Package org.apache.ibatis.mapping

Examples of org.apache.ibatis.mapping.MappedStatement


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

    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


    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, null, 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

        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
        configReader.close();

        Configuration configuration = sqlSessionFactory.getConfiguration();

        MappedStatement selectPerson = configuration.getMappedStatement("person namespace.select");
        assertEquals(
                "org/apache/ibatis/submitted/xml_external_ref/NonFullyQualifiedNamespacePersonMapper.xml",
                selectPerson.getResource());

        Connection conn = configuration.getEnvironment().getDataSource().getConnection();
        initDb(conn);

        SqlSession sqlSession = sqlSessionFactory.openSession();
View Full Code Here

public class ShortNameTest {
    @Test
    public void getStatementByShortName() throws Exception {
        Configuration configuration = getConfiguration();
        // statement can be referenced by its short name.
        MappedStatement selectPet = configuration.getMappedStatement("selectPet");
        assertNotNull(selectPet);
    }
View Full Code Here

    DataSource ds = createBlogDataSource();
    Connection connection = ds.getConnection();
    Executor executor = createExecutor(new JdbcTransaction(connection, false));
    try {
      Author author = new Author(-1, "someone", "******", "someone@apache.org", null, Section.NEWS);
      MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorMappedStatementWithBeforeAutoKey(config);
      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
      int rows = executor.update(insertStatement, author);
      assertTrue(rows > 0 || rows == BatchExecutor.BATCH_UPDATE_RETURN_VALUE);
      if (rows == BatchExecutor.BATCH_UPDATE_RETURN_VALUE) {
        executor.flushStatements();
      }
View Full Code Here

    DataSource ds = createBlogDataSource();
    Connection connection = ds.getConnection();
    Executor executor = createExecutor(new JdbcTransaction(connection, false));
    try {
      Author author = new Author(99, "someone", "******", "someone@apache.org", null, Section.NEWS);
      MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorMappedStatement(config);
      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
      int rows = executor.update(insertStatement, author);
      List<Author> authors = executor.query(selectStatement, 99, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
      executor.flushStatements();
      executor.rollback(true);
      assertEquals(1, authors.size());
View Full Code Here

  public void shouldSelectAllAuthorsAutoMapped() throws Exception {
    DataSource ds = createBlogDataSource();
    Connection connection = ds.getConnection();
    Executor executor = createExecutor(new JdbcTransaction(connection, false));
    try {
      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAllAuthorsAutoMappedStatement(config);
      List<Author> authors = executor.query(selectStatement, null, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
      assertEquals(2, authors.size());
      Author author = authors.get(0);
      // id,username, password, email, bio, favourite_section
      // (101,'jim','********','jim@ibatis.apache.org','','NEWS');
 
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.