Spring Batch: ItemProcessor query Database?

hell--raiser

I have a scenario where I need to parse flat files and process those records into mysql database inserts (schema already exists).

I'm using the FlatFileItemReader to parse the files and a JdbcCursorItemWriter to insert in the database.

I'm also using an ItemProcessor to convert any column values or skip records that I don't want.

My problem is, some of those inserts need to have a foreign key to some other table that already has data into it.

So I was thinking to do a select to retrieve the ID and update the pojo, inside the ItemProcessor logic.

Is this the best way to do it? I can consider alternatives as I'm just beginning to write all this.

Thanks!

Michael Minella

The ItemProcessor in a Spring Batch step is commonly used for enrichment of data and querying a db for something like that is common.

For the record, another option would be to use a sub select in your insert statement to get the foreign key value as the record is being inserted. This may be a bit more performant give it removes the additional db hit.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

override spring batch admin to use mysql database

From Dev

Fastest way to batch query an ORACLE Database with Java

From Dev

Spring-Batch without persisting metadata to database?

From Dev

Spring-Batch how to write job metdata in different database?

From Dev

Spring Batch - If database access failed while running the JOB

From Dev

Use a query that takes parameters in Spring Batch

From Dev

Spring Batch | MongoItemReader | How to pass JobParameters to mongo query?

From Dev

Spring batch - using in-memory database for huge file processing

From Dev

Query batch job metadata in Spring batch

From Dev

Spring Batch Database Dependency pass parameters to SQL statement

From Dev

Only half of the MongoDB database is being processed in Spring batch

From Dev

Spring Batch Reader for distributed DB2 database

From Dev

Rollback fail : connection closed after database restart on Spring-batch

From Dev

Spring batch composite item Writers with optional database writes

From Dev

spring boot and spring batch throw NullPointerException in DAO of ItemProcessor batch

From Dev

Will the SELECT Query be able to retrieve 200K records in Spring Batch

From Dev

Fastest way to batch query an ORACLE Database with Java

From Dev

When constructors for ItemReader, ItemProcessor, ItemWriter are called in Spring Batch?

From Dev

override spring batch admin to use mysql database

From Dev

Spring Batch | MongoItemReader | How to pass JobParameters to mongo query?

From Dev

Spring Batch Execution Status Backed by Database

From Dev

Spring batch ItemProcessor order of processing the items

From Dev

Spring batch JpaPagingItemReader (possibly) removes rows from the database while using SELECT native query

From Dev

Spring JDBC batch update query without prepared statements

From Dev

spring batch dynamic query to itemreader

From Dev

Database and Meta DB table for Spring batch

From Dev

Spring Batch: ItemProcessor does not process all records

From Dev

Load Multiple CSV files into database using Spring Batch

From Dev

Spring Batch JpaPagingItemReader: how to set a query hint?

Related Related

  1. 1

    override spring batch admin to use mysql database

  2. 2

    Fastest way to batch query an ORACLE Database with Java

  3. 3

    Spring-Batch without persisting metadata to database?

  4. 4

    Spring-Batch how to write job metdata in different database?

  5. 5

    Spring Batch - If database access failed while running the JOB

  6. 6

    Use a query that takes parameters in Spring Batch

  7. 7

    Spring Batch | MongoItemReader | How to pass JobParameters to mongo query?

  8. 8

    Spring batch - using in-memory database for huge file processing

  9. 9

    Query batch job metadata in Spring batch

  10. 10

    Spring Batch Database Dependency pass parameters to SQL statement

  11. 11

    Only half of the MongoDB database is being processed in Spring batch

  12. 12

    Spring Batch Reader for distributed DB2 database

  13. 13

    Rollback fail : connection closed after database restart on Spring-batch

  14. 14

    Spring batch composite item Writers with optional database writes

  15. 15

    spring boot and spring batch throw NullPointerException in DAO of ItemProcessor batch

  16. 16

    Will the SELECT Query be able to retrieve 200K records in Spring Batch

  17. 17

    Fastest way to batch query an ORACLE Database with Java

  18. 18

    When constructors for ItemReader, ItemProcessor, ItemWriter are called in Spring Batch?

  19. 19

    override spring batch admin to use mysql database

  20. 20

    Spring Batch | MongoItemReader | How to pass JobParameters to mongo query?

  21. 21

    Spring Batch Execution Status Backed by Database

  22. 22

    Spring batch ItemProcessor order of processing the items

  23. 23

    Spring batch JpaPagingItemReader (possibly) removes rows from the database while using SELECT native query

  24. 24

    Spring JDBC batch update query without prepared statements

  25. 25

    spring batch dynamic query to itemreader

  26. 26

    Database and Meta DB table for Spring batch

  27. 27

    Spring Batch: ItemProcessor does not process all records

  28. 28

    Load Multiple CSV files into database using Spring Batch

  29. 29

    Spring Batch JpaPagingItemReader: how to set a query hint?

HotTag

Archive