Results 1 to 2 of 2

Thread: Itemreader read method while dealing with collections

Hybrid View

  1. #1

    Default Itemreader read method while dealing with collections

    Hi,

    I have created custom item reader by implementing the ItemReader interface.
    From the read method i am calling a business method which will return collection of items.

    public Product read () {

    // calling business method ,returns a list of products.

    }

    According to the commit-interval , how can we return items from reader to writer.

    let say , the list contains 100 products and the commit interval is 10.

    So , i need to return bunch of 10 products to the item writer.

    How we can achieve this?

    Regards,
    Siva

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    ItemReader<Product> returns a Product (singular) from its read() method. If you can only read them as a collection you can either use ItemReader<Collection<Product>> or you can buffer them inside the reader (and if you do the latter either forget about restartability, or implement ItemStream to count the items and re-position on restart).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •