Can I use Spring JdbcTemplate in Spring Batch Job Implementation?

jalpa

As per the Spring Batch Documentation, it provides the variety of flavors to read data from the database as ItemReader. In my case, there are lots of business validation needs to be performed against the database. Let's say after reading data from any of the below source, I wanted to validate them against the multiple databases, Can I use Spring JdbcTemplate in Spring Batch Job Implementation?

 1. HibernatePagingItemReader 
 2. HibernateCursorItemReader
 3. JpaPagingItemReader 
 4. JdbcPagingItemReader
 5. JdbcCursorItemReader
Sabir Khan

You can use whatever mechanism you desire including JdbcTemplate to read database with Spring Batch. Spring Batch as a framework doesn't put any such restrictions.

Spring Batch has those convenient readers ( listed by you ) for simple use cases and if those don't fit in your requirement, you are very free to write your own readers too.

JdbcPagingItemReader itself uses a NamedParameterJdbcTemplate created on datasource that you provide.

You requirement is not very clear to me but I guess, you can do any of the two tasks,

1.Composite Reader - You write your own composite reader and use one of Spring Batch readers as first reader then put in validation logic on those read items

2.Validate in Processor - Read your items with Spring Batch provided readers then process / validate in processor. Chaining of processors is possible in Spring Batch - Chaining ItemProcessors so you can put different transformations if different processors and produce a final output after a chain.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Disable transactions in my Spring Batch job

分類Dev

Testing of spring batch job causes unexpected results

分類Dev

Spring Batch Persist Job Meta Data

分類Dev

NoSuchJobException when running a job programmatically in Spring Batch

分類Dev

Spring Batch job execution status in response body

分類Dev

pass job parameters to custom writer Spring batch

分類Dev

Spring jdbcTemplate OneToMany

分類Dev

JPA対Spring JdbcTemplate

分類Dev

Spring JdbcTemplate and @Transactional not flushing

分類Dev

Spring SimpleJdbcInsert vs JdbcTemplate

分類Dev

Spring batch when use steps deciders and chunks

分類Dev

java Spring JDBCTemplate - where 句

分類Dev

Can I use Spring's MockMvc with Jersey resources?

分類Dev

How can I use Spring 3.2.3 JavaConfig to read an environment variable?

分類Dev

How can I know the total number of chunks/items to be processed at the beginning of a Spring Batch Step?

分類Dev

Spring Batchは常にSpring Bootで始まります:spring.batch.job.enabled = false動作しません

分類Dev

Spring Batch + Spring Boot + Couchbase

分類Dev

Spring jdbcTemplate単体テスト

分類Dev

Spring JdbcTemplateとスレッド

分類Dev

Spring JdbcTemplate with parameter returns empty List

分類Dev

Springの静的JdbcTemplateの代替

分類Dev

Spring Boot + Spring Batch + Spring JPA

分類Dev

無限ループで実行されているSpring Batch Job

分類Dev

プログラムでSpring Batch Jobを実行しますか?

分類Dev

How to access execution context from a Spring Batch Step? Error: No context holder available for job scope

分類Dev

Does every job call in Spring Batch open a new database connection pool?

分類Dev

Deadlock while purging old records of spring batch job tables at scheduled time using shedlock

分類Dev

Spring Autowiring, I only have one implementation should I autowire? And if so, should I autowire the implementation?

分類Dev

Spring Autowiring, I only have one implementation should I autowire? And if so, should I autowire the implementation?

Related 関連記事

  1. 1

    Disable transactions in my Spring Batch job

  2. 2

    Testing of spring batch job causes unexpected results

  3. 3

    Spring Batch Persist Job Meta Data

  4. 4

    NoSuchJobException when running a job programmatically in Spring Batch

  5. 5

    Spring Batch job execution status in response body

  6. 6

    pass job parameters to custom writer Spring batch

  7. 7

    Spring jdbcTemplate OneToMany

  8. 8

    JPA対Spring JdbcTemplate

  9. 9

    Spring JdbcTemplate and @Transactional not flushing

  10. 10

    Spring SimpleJdbcInsert vs JdbcTemplate

  11. 11

    Spring batch when use steps deciders and chunks

  12. 12

    java Spring JDBCTemplate - where 句

  13. 13

    Can I use Spring's MockMvc with Jersey resources?

  14. 14

    How can I use Spring 3.2.3 JavaConfig to read an environment variable?

  15. 15

    How can I know the total number of chunks/items to be processed at the beginning of a Spring Batch Step?

  16. 16

    Spring Batchは常にSpring Bootで始まります:spring.batch.job.enabled = false動作しません

  17. 17

    Spring Batch + Spring Boot + Couchbase

  18. 18

    Spring jdbcTemplate単体テスト

  19. 19

    Spring JdbcTemplateとスレッド

  20. 20

    Spring JdbcTemplate with parameter returns empty List

  21. 21

    Springの静的JdbcTemplateの代替

  22. 22

    Spring Boot + Spring Batch + Spring JPA

  23. 23

    無限ループで実行されているSpring Batch Job

  24. 24

    プログラムでSpring Batch Jobを実行しますか?

  25. 25

    How to access execution context from a Spring Batch Step? Error: No context holder available for job scope

  26. 26

    Does every job call in Spring Batch open a new database connection pool?

  27. 27

    Deadlock while purging old records of spring batch job tables at scheduled time using shedlock

  28. 28

    Spring Autowiring, I only have one implementation should I autowire? And if so, should I autowire the implementation?

  29. 29

    Spring Autowiring, I only have one implementation should I autowire? And if so, should I autowire the implementation?

ホットタグ

アーカイブ