@Override protected void doJumpToPage(int itemIndex) { /* * Normally this would be false (the startAfterValue is enough * information to restart from. */ // TODO: this is dead code, startAfterValues is never null - see #open(ExecutionContext) if (startAfterValues == null && getPage() > 0) { String jumpToItemSql = queryProvider.generateJumpToItemQuery(itemIndex, getPageSize()); if (logger.isDebugEnabled()) { logger.debug("SQL used for jumping: [" + jumpToItemSql + "]"); } if (this.queryProvider.isUsingNamedParameters()) { startAfterValues = namedParameterJdbcTemplate.queryForMap(jumpToItemSql, getParameterMap(parameterValues, null)); } else { startAfterValues = getJdbcTemplate().queryForMap(jumpToItemSql, getParameterList(parameterValues, null).toArray()); } } }
@Test @Ignore public void testJumpToItem() throws Exception { PagingQueryProvider queryProvider = getPagingQueryProvider(); int minId = jdbcTemplate.queryForObject("SELECT MIN(VALUE) FROM T_FOOS", Integer.class); String query = queryProvider.generateJumpToItemQuery(pageSize, pageSize); List<Map<String, Object>> list = jdbcTemplate.queryForList(query); logger.debug("Jump to page result: " + list); assertEquals(1, list.size()); System.err.println(list); String expected = "[{value=" + (minId + pageSize - 1); assertEquals(expected, list.toString().toLowerCase().substring(0, expected.length())); Object startAfterValue = list.get(0).entrySet().iterator().next().getValue(); list = jdbcTemplate.queryForList(queryProvider.generateRemainingPagesQuery(pageSize), startAfterValue); assertEquals(pageSize, list.size()); expected = "[{id=" + (minId + pageSize); }
@Override protected void doJumpToPage(int itemIndex) { /* * Normally this would be false (the startAfterValue is enough * information to restart from. */ // TODO: this is dead code, startAfterValues is never null - see #open(ExecutionContext) if (startAfterValues == null && getPage() > 0) { String jumpToItemSql = queryProvider.generateJumpToItemQuery(itemIndex, getPageSize()); if (logger.isDebugEnabled()) { logger.debug("SQL used for jumping: [" + jumpToItemSql + "]"); } if (this.queryProvider.isUsingNamedParameters()) { startAfterValues = namedParameterJdbcTemplate.queryForMap(jumpToItemSql, getParameterMap(parameterValues, null)); } else { startAfterValues = getJdbcTemplate().queryForMap(jumpToItemSql, getParameterList(parameterValues, null).toArray()); } } }
try { Long startAfterValue = getJdbcTemplate().queryForObject( queryProvider.generateJumpToItemQuery(start, count), Long.class, jobName, stepName); stepExecutions = getJdbcTemplate().query(queryProvider.generateRemainingPagesQuery(count), new StepExecutionRowMapper(), jobName, stepName, startAfterValue);
try { Long startAfterValue = getJdbcTemplate().queryForObject( queryProvider.generateJumpToItemQuery(start, count), Long.class, jobName, stepName); stepExecutions = getJdbcTemplate().query(queryProvider.generateRemainingPagesQuery(count), new StepExecutionRowMapper(), jobName, stepName, startAfterValue);
@Override public List<JobExecutionWithStepCount> getJobExecutionsWithStepCount(int start, int count) { if (start <= 0) { return getJdbcTemplate().query(executionsWithStepCountPagingQueryProvider.generateFirstPageQuery(count), new JobExecutionStepCountRowMapper()); } try { Long startAfterValue = getJdbcTemplate().queryForObject( executionsWithStepCountPagingQueryProvider.generateJumpToItemQuery(start, count), Long.class); return getJdbcTemplate().query(executionsWithStepCountPagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionStepCountRowMapper(), startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
@Override public List<JobExecution> getJobExecutions(final String jobName, final int start, final int count) { if (start <= 0) { return this.getJdbcTemplate().query(this.byJobNamePagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper(), jobName); } try { final Long startAfterValue = this.getJdbcTemplate().queryForObject( this.byJobNamePagingQueryProvider.generateJumpToItemQuery(start, count), Long.class, jobName); return this.getJdbcTemplate().query(this.byJobNamePagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(), jobName, startAfterValue); } catch (final IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
/** * @see SearchableJobExecutionDao#getJobExecutionsWithStepCount(String, int, int) */ @Override public List<JobExecutionWithStepCount> getJobExecutionsWithStepCount(String jobName, int start, int count) { if (start <= 0) { return getJdbcTemplate().query(byJobNameWithStepCountPagingQueryProvider.generateFirstPageQuery(count), new JobExecutionStepCountRowMapper(), jobName); } try { Long startAfterValue = getJdbcTemplate().queryForObject( byJobNameWithStepCountPagingQueryProvider.generateJumpToItemQuery(start, count), Long.class, jobName); return getJdbcTemplate().query(byJobNameWithStepCountPagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionStepCountRowMapper(), jobName, startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
/** * @see SearchableJobExecutionDao#getJobExecutions(String, int, int) */ @Override public List<JobExecution> getJobExecutions(String jobName, int start, int count) { if (start <= 0) { return getJdbcTemplate().query(byJobNamePagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper(), jobName); } try { Long startAfterValue = getJdbcTemplate().queryForObject( byJobNamePagingQueryProvider.generateJumpToItemQuery(start, count), Long.class, jobName); return getJdbcTemplate().query(byJobNamePagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(), jobName, startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
/** * @see SearchableJobExecutionDao#getJobExecutions(int, int) */ @Override public List<JobExecution> getJobExecutions(int start, int count) { if (start <= 0) { return getJdbcTemplate().query(allExecutionsPagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper()); } try { Long startAfterValue = getJdbcTemplate().queryForObject( allExecutionsPagingQueryProvider.generateJumpToItemQuery(start, count), Long.class); return getJdbcTemplate().query(allExecutionsPagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(), startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
/** * @see SearchableJobExecutionDao#getJobExecutions(int, int) */ @Override public List<JobExecution> getJobExecutions(int start, int count) { if (start <= 0) { return getJdbcTemplate().query(allExecutionsPagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper()); } try { Long startAfterValue = getJdbcTemplate().queryForObject( allExecutionsPagingQueryProvider.generateJumpToItemQuery(start, count), Long.class); return getJdbcTemplate().query(allExecutionsPagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(), startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
/** * @see SearchableJobExecutionDao#getJobExecutions(String, int, int) */ @Override public List<JobExecution> getJobExecutions(String jobName, int start, int count) { if (start <= 0) { return getJdbcTemplate().query(byJobNamePagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper(), jobName); } try { Long startAfterValue = getJdbcTemplate().queryForObject( byJobNamePagingQueryProvider.generateJumpToItemQuery(start, count), Long.class, jobName); return getJdbcTemplate().query(byJobNamePagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(), jobName, startAfterValue); } catch (IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }
@Override public List<JobExecution> findJobExecutions(final JobInstance jobInstance, final int start, final int count) { if (start <= 0) { return this.getJdbcTemplate().query(this.byJobInstanceIdExecutionsPagingQueryProvider.generateFirstPageQuery(count), new JobExecutionRowMapper(jobInstance), jobInstance.getInstanceId()); } try { final Long startAfterValue = this.getJdbcTemplate().queryForObject( this.byJobInstanceIdExecutionsPagingQueryProvider.generateJumpToItemQuery(start, count), Long.class, jobInstance.getInstanceId()); return this.getJdbcTemplate().query( this.byJobInstanceIdExecutionsPagingQueryProvider.generateRemainingPagesQuery(count), new JobExecutionRowMapper(jobInstance), jobInstance.getInstanceId(), startAfterValue); } catch (final IncorrectResultSizeDataAccessException e) { return Collections.emptyList(); } }