[Spring Batch] (For forgot) What ItemReader should do

ItemReader get batch target object.

T read() method called until it returns null.
Therefore Spring batch would do something like below.

  1. Read record(s) by ItemReader.
  2. Do something at ItemProcessor.
  3. Write results at ItemWriter. When writing results, set flag or delete source data so that ItemReader would not to read same data again.

Or you can do like below. But you should be aware of exception handling.

  1. Read all target records and cached them at ItemReader.Then ItemReader returns one(or some) record(s).
  2. Do something at ItemProcessor.
  3. Write something at ItemWriter.

In this case, ItemReader keep records and current position.
To do this, you must define the ItemReader with scope=”step” in Bean Configuration.
scope=”step” means instance lifecycle is Step.
So you can keep current position as class member and it keeps until ItemReader returns null.

[Grails] GORM Embedded table column which declared as a member (property)

Normally member(property) would be mapped as a parent-child relationship, but uses embedded would be mapped as a one table.

Person has a Address object.

And Address class is like below.

Declare as a embedded property, Person table mapped as below.

  • id
  • home_address_number
  • home_address_code
  • work_address_number
  • work_address_code

Each column names are concatenated with _(an underscore) and the parent object name and the child object name.