Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.ResultHandler


  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


          }
        }).build();

    final Executor executor = null;
    final ParameterHandler parameterHandler = null;
    final ResultHandler resultHandler = null;
    final BoundSql boundSql = null;
    final RowBounds rowBounds = new RowBounds(0, 100);
    final DefaultResultSetHandler fastResultSetHandler = new DefaultResultSetHandler(executor, ms, parameterHandler, resultHandler, boundSql, rowBounds);

    when(stmt.getResultSet()).thenReturn(rs);
View Full Code Here

    SqlSession sqlSession = sqlSessionFactory.openSession();
    final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    Date targetMonth = fmt.parse("2014-01-01");
    final List<Account> accounts = new ArrayList<Account>();
    try {
      sqlSession.select("collectPageByBirthMonth", targetMonth, new RowBounds(1, 2), new ResultHandler() {
        @Override
        public void handleResult(ResultContext context) {
          Account account = (Account) context.getResultObject();
          accounts.add(account);
        }
View Full Code Here

    SqlSession sqlSession = sqlSessionFactory.openSession();
    final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    final List<Account> accounts = new ArrayList<Account>();
    try {
      Date targetMonth = fmt.parse("2014-01-01");
      sqlSession.select("collectPageByBirthMonth", targetMonth, new ResultHandler() {
        @Override
        public void handleResult(ResultContext context) {
          Account account = (Account) context.getResultObject();
          accounts.add(account);
          if (accounts.size() > 1)
View Full Code Here

  @Test
  // issue #542
  public void testGetPersonWithHandler() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
      sqlSession.select("getPersons", new ResultHandler() {
        public void handleResult(ResultContext context) {
          Person person = (Person) context.getResultObject();
          if ("grandma".equals(person.getName())) {
            Assert.assertEquals(2, person.getItems().size());
          }
View Full Code Here

  @Test(expected=PersistenceException.class)
  public void testUnorderedGetPersonWithHandler() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
      sqlSession.select("getPersonsWithItemsOrdered", new ResultHandler() {
        public void handleResult(ResultContext context) {
          Person person = (Person) context.getResultObject();
          if ("grandma".equals(person.getName())) {
            Assert.assertEquals(2, person.getItems().size());
          }
View Full Code Here

   */
  public ResourceIndexerDao indexProjects() {
    final DbSession session = mybatis.openSession(true);
    try {
      final ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
      session.select("org.sonar.core.resource.ResourceIndexerMapper.selectRootProjectIds", /* workaround to get booleans */ResourceIndexerQuery.create(), new ResultHandler() {
        @Override
        public void handleResult(ResultContext context) {
          Integer rootProjectId = (Integer) context.getResultObject();
          doIndexProject(rootProjectId, session, mapper);
          session.commit();
View Full Code Here

      .setNonIndexedOnly(true)
      .setQualifiers(NOT_RENAMABLE_QUALIFIERS)
      .setScopes(NOT_RENAMABLE_SCOPES)
      .setRootProjectId(rootProjectId);

    session.select(SELECT_RESOURCES, query, new ResultHandler() {
      @Override
      public void handleResult(ResultContext context) {
        ResourceDto resource = (ResourceDto) context.getResultObject();
        doIndex(resource, mapper);
      }
    });

    // some resources can be renamed, so index must be regenerated
    // -> delete existing rows and create them again
    query = ResourceIndexerQuery.create()
      .setNonIndexedOnly(false)
      .setQualifiers(RENAMABLE_QUALIFIERS)
      .setScopes(RENAMABLE_SCOPES)
      .setRootProjectId(rootProjectId);

    session.select(SELECT_RESOURCES, query, new ResultHandler() {
      @Override
      public void handleResult(ResultContext context) {
        ResourceDto resource = (ResourceDto) context.getResultObject();

        mapper.deleteByResourceId(resource.getId());
View Full Code Here

      purgeCommands.purgeSnapshots(PurgeSnapshotQuery.create().setId(projectSnapshotId).setNotPurged(true));
    }
  }

  private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper) {
    session.select("org.sonar.core.purge.PurgeMapper.selectResourceIdsToDisable", project.getId(), new ResultHandler() {
      @Override
      public void handleResult(ResultContext resultContext) {
        Long resourceId = (Long) resultContext.getResultObject();
        if (resourceId != null) {
          disableResource(resourceId, purgeMapper);
View Full Code Here

    final List<DependencyDto> dependencies = Lists.newArrayList();

    SqlSession session = getMyBatis().openSession();
    try {
      session.getMapper(DependencyMapper.class).selectAll(new ResultHandler() {
        public void handleResult(ResultContext context) {
          dependencies.add((DependencyDto) context.getResultObject());
        }
      });
    } finally {
View Full Code Here

TOP

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

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.