Java Code Examples for org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean#setFromClause()
The following examples show how to use
org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean#setFromClause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobConfiguration.java From CogStack-Pipeline with Apache License 2.0 | 5 votes |
@Bean @StepScope @Qualifier("documentItemReader") @Profile("jdbc_in") public ItemReader<Document> documentItemReader( @Value("#{stepExecutionContext[minValue]}") String minValue, @Value("#{stepExecutionContext[maxValue]}") String maxValue, @Value("#{stepExecutionContext[min_time_stamp]}") String minTimeStamp, @Value("#{stepExecutionContext[max_time_stamp]}") String maxTimeStamp, @Qualifier("documentRowMapper")RowMapper<Document> documentRowmapper, @Qualifier("sourceDataSource") DataSource jdbcDocumentSource) throws Exception { JdbcPagingItemReader<Document> reader = new JdbcPagingItemReader<>(); reader.setDataSource(jdbcDocumentSource); // read and set obligatory properties SqlPagingQueryProviderFactoryBean qp = new SqlPagingQueryProviderFactoryBean(); qp.setSelectClause(env.getRequiredProperty("source.selectClause")); qp.setFromClause(env.getRequiredProperty("source.fromClause")); qp.setSortKey(env.getRequiredProperty("source.sortKey")); qp.setWhereClause(stepPartitioner.getPartitioningLogic(minValue,maxValue, minTimeStamp,maxTimeStamp)); qp.setDataSource(jdbcDocumentSource); // set optional properties if (env.containsProperty("source.pageSize")) { reader.setPageSize(Integer.parseInt(env.getProperty("source.pageSize"))); } else { // it's a good idea to batch size and page size (commit interval) set to the same value LOG.info("property: 'source.pageSize' not specified -> setting DB reader page size to batch step chunk size: {}", chunkSize); reader.setPageSize(chunkSize); } reader.setQueryProvider(qp.getObject()); reader.setRowMapper(documentRowmapper); return reader; }
Example 2
Source File: JdbcSearchableStepExecutionDao.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * @return a {@link PagingQueryProvider} with a where clause to narrow the * query * @throws Exception */ private PagingQueryProvider getPagingQueryProvider(String whereClause) { SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(dataSource); factory.setFromClause(getQuery("%PREFIX%STEP_EXECUTION S, %PREFIX%JOB_EXECUTION J, %PREFIX%JOB_INSTANCE I")); factory.setSelectClause(FIELDS); Map<String, Order> sortKeys = new HashMap<String, Order>(); sortKeys.put("STEP_EXECUTION_ID", Order.DESCENDING); factory.setSortKeys(sortKeys); if (whereClause != null) { factory.setWhereClause(whereClause + " AND S.JOB_EXECUTION_ID = J.JOB_EXECUTION_ID AND J.JOB_INSTANCE_ID = I.JOB_INSTANCE_ID"); } try { return (PagingQueryProvider) factory.getObject(); } catch (Exception e) { throw new IllegalStateException("Unexpected exception creating paging query provide", e); } }
Example 3
Source File: JdbcSearchableJobExecutionDao.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * @return a {@link PagingQueryProvider} with a where clause to narrow the * query * @throws Exception if page provider is not created. */ private PagingQueryProvider getPagingQueryProvider(String fields, String fromClause, String whereClause) throws Exception { SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(dataSource); fromClause = "%PREFIX%JOB_EXECUTION E, %PREFIX%JOB_INSTANCE I" + (fromClause == null ? "" : ", " + fromClause); factory.setFromClause(getQuery(fromClause)); if(fields == null) { fields = FIELDS; } factory.setSelectClause(getQuery(fields)); Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("JOB_EXECUTION_ID", Order.DESCENDING); factory.setSortKeys(sortKeys); whereClause = "E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID" + (whereClause == null ? "" : " and " + whereClause); factory.setWhereClause(whereClause); return factory.getObject(); }
Example 4
Source File: JdbcLightminJobExecutionDao.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
/** * @return a {@link PagingQueryProvider} with a where clause to narrow the * query * @throws Exception */ private PagingQueryProvider getPagingQueryProvider(String fromClause, String whereClause) throws Exception { final SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(this.dataSource); fromClause = "%PREFIX%JOB_EXECUTION E, %PREFIX%JOB_INSTANCE I" + (fromClause == null ? "" : ", " + fromClause); factory.setFromClause(this.getQuery(fromClause)); factory.setSelectClause(FIELDS); final Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("JOB_EXECUTION_ID", Order.DESCENDING); factory.setSortKeys(sortKeys); whereClause = "E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID" + (whereClause == null ? "" : " and " + whereClause); factory.setWhereClause(whereClause); return factory.getObject(); }
Example 5
Source File: JdbcLightminJobExecutionDao.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
private PagingQueryProvider getPagingQueryProviderForQueryService(String fromClause, String whereClause, final Boolean withJobName) throws Exception { final SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(this.dataSource); fromClause = "%PREFIX%JOB_EXECUTION E, %PREFIX%JOB_INSTANCE I" + (fromClause == null ? "" : ", " + fromClause); factory.setFromClause(this.getQuery(fromClause)); factory.setSelectClause(FIELDS); final Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("JOB_EXECUTION_ID", Order.DESCENDING); factory.setSortKeys(sortKeys); whereClause = "%s E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID" + (whereClause == null ? "" : whereClause); if (withJobName) { whereClause = String.format(whereClause, " I.JOB_NAME=? AND "); } else { whereClause = String.format(whereClause, ""); } factory.setWhereClause(whereClause); return factory.getObject(); }
Example 6
Source File: JdbcSchedulerConfigurationRepository.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
private PagingQueryProvider getPagingQueryProvider(String fromClause, String whereClause) throws Exception { final SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(this.jdbcTemplate.getDataSource()); fromClause = "%s S" + (fromClause == null ? "" : ", " + fromClause); factory.setFromClause(String.format(fromClause, this.tableName)); factory.setSelectClause(FIELDS); final Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("id", Order.ASCENDING); factory.setSortKeys(sortKeys); whereClause = whereClause == null ? "" : whereClause; factory.setWhereClause(whereClause); return factory.getObject(); }
Example 7
Source File: JdbcSchedulerExecutionRepository.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
private PagingQueryProvider getPagingQueryProvider(String fromClause, String whereClause) throws Exception { final SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean(); factory.setDataSource(this.jdbcTemplate.getDataSource()); fromClause = "%s S" + (fromClause == null ? "" : ", " + fromClause); factory.setFromClause(String.format(fromClause, this.tableName)); factory.setSelectClause(FIELDS); final Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("id", Order.DESCENDING); factory.setSortKeys(sortKeys); whereClause = whereClause == null ? "" : whereClause; factory.setWhereClause(whereClause); return factory.getObject(); }