Package org.springframework.batch.item.database

Examples of org.springframework.batch.item.database.PagingQueryProvider


    factory.setSelectClause(selectClause);
   
    factory.setWhereClause(whereClause);
    factory.setSortKey(sortClause);
   
    PagingQueryProvider queryProvider = null;
    try {
      queryProvider = (PagingQueryProvider)factory.getObject();
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
      return null;
    }
   
    String query = queryProvider.generateFirstPageQuery(maxResult);
   
   
    //this.getJdbcTemplate().setQueryTimeout(1000); 
   
   
View Full Code Here


    }
    else {
      whereClause = whereClause + " AND STEP_NAME = ?";
    }

    PagingQueryProvider queryProvider = getPagingQueryProvider(whereClause);

    List<StepExecution> stepExecutions;
    if (start <= 0) {
      stepExecutions = getJdbcTemplate().query(queryProvider.generateFirstPageQuery(count),
          new StepExecutionRowMapper(), jobName, stepName);
    }
    else {
      try {
        Long startAfterValue = getJdbcTemplate().queryForObject(
            queryProvider.generateJumpToItemQuery(start, count), Long.class, jobName, stepName);
        stepExecutions = getJdbcTemplate().query(queryProvider.generateRemainingPagesQuery(count),
            new StepExecutionRowMapper(), jobName, stepName, startAfterValue);
      }
      catch (IncorrectResultSizeDataAccessException e) {
        return Collections.emptyList();
      }
View Full Code Here

    factory.setDataSource(dataSource);
  }

  @Test
  public void testFactory() throws Exception {
    PagingQueryProvider provider = factory.getObject();
    assertNotNull(provider);
  }
View Full Code Here

  }

  @Test(expected=IllegalArgumentException.class)
  public void testNoDataSource() throws Exception {
    factory.setDataSource(null);
    PagingQueryProvider provider = factory.getObject();
    assertNotNull(provider);
  }
View Full Code Here

  }

  @Test(expected=IllegalArgumentException.class)
  public void testNoSortKey() throws Exception {
    factory.setSortKeys(null);
    PagingQueryProvider provider = factory.getObject();
    assertNotNull(provider);
  }
View Full Code Here

  }

  @Test
  public void testWhereClause() throws Exception {
    factory.setWhereClause("x=y");
    PagingQueryProvider provider = factory.getObject();
    String query = provider.generateFirstPageQuery(100);
    assertTrue("Wrong query: "+query, query.contains("x=y"));
  }
View Full Code Here

    assertTrue("Wrong query: "+query, query.contains("x=y"));
  }

  @Test
  public void testAscending() throws Exception {
    PagingQueryProvider provider = factory.getObject();
    String query = provider.generateFirstPageQuery(100);
    assertTrue("Wrong query: "+query, query.contains("ASC"));
  }
View Full Code Here

  }

  @Test(expected=IllegalArgumentException.class)
  public void testWrongDatabaseType() throws Exception {
    factory.setDatabaseType("NoSuchDb");
    PagingQueryProvider provider = factory.getObject();
    assertNotNull(provider);
  }
View Full Code Here

  }

  @Test(expected=IllegalArgumentException.class)
  public void testMissingMetaData() throws Exception {
    factory.setDataSource(DatabaseTypeTestUtils.getMockDataSource(new MetaDataAccessException("foo")));
    PagingQueryProvider provider = factory.getObject();
    assertNotNull(provider);
  }
View Full Code Here

  @Test
  public void testAllDatabaseTypes() throws Exception {
    for (DatabaseType type : DatabaseType.values()) {
      factory.setDatabaseType(type.name());
      PagingQueryProvider provider = factory.getObject();
      assertNotNull(provider);     
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.database.PagingQueryProvider

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.