Results 1 to 7 of 7

Thread: BeanWrapperFieldSetMapper - Is this a JIRA issue?

  1. #1

    Default BeanWrapperFieldSetMapper - Is this a JIRA issue?

    Hi,

    I am using the BeanWrapperFieldSetMapper, to convert the file content to Object. If I have the below class structure

    Code:
    public class A{
       int attrA1;
       int attrA2;
    }
    
    public class B{
        A classAinst;
    }
    When feeding the file for Object B using BeanWrapperFieldSetMapper below line of code

    Code:
    	public Object mapLine(FieldSet fs) {
    		Object copy = getBean();
    creates only object B with null instance of A. This throws an NullPointerException.

    Question: Is this an bug in the code or there is a way to handle it. Instantiating the classAinst in the constructor B is not an option as Class B is also used by UI/core business classes.

    Your answer to this question is much appreciated. Thanks in advance for your help.

    Thanks,
    vbforums

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

    Default

    BeanWrapperFieldSetMapper has a prototypeBeanName property which you need to use if there are complex configuration or instantiation requirements (i.e. as in your case where the default constructor doesn't provide a fully formed prototype).

  3. #3

    Default

    Agreed, this resolves the issue of NULL child object.

    Another problem that I see is, lets say class A mapped to tableA and class B mapped to tableB, if all the parameters of class B is null in the file(for some rows) this creates a dummy row in tableB.

    Is there is a way to avoid this?

  4. #4
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    Insert a validation check or ItemProcessor (2.0) / ItemTransformer (1.x) that removes empty elements?

  5. #5

    Default

    Thanks for your response and guidance Dave. I will go this route.

    If this checking is in-built in the batch framework its a nice to have else we have to build a class for each of our batch operations to perform.

    Also, can you please respond to my other thread, I am eagerly waiting for some one to reply. Topic "Retrieving Error message, skipped record, line number "

    http://forum.springframework.org/showthread.php?t=62970

  6. #6
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    Quote Originally Posted by vbforums View Post
    If this checking is in-built in the batch framework its a nice to have else we have to build a class for each of our batch operations to perform.
    If you open an issue in JIRA you'll give people a chance to comment and vote. You'll need to be a bit more precise about the new feature though.

  7. #7

    Default

    Yep, I have created the below JIRA issue for this

    http://jira.springframework.org/browse/BATCH-924
    Last edited by Dave Syer; Nov 13th, 2008 at 11:52 AM. Reason: make url clickable

Posting Permissions

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