Announcement Announcement Module
Collapse
No announcement yet.
BeanWrapperFieldSetMapper - Is this a JIRA issue? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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).

    Comment


    • #3
      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?

      Comment


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

        Comment


        • #5
          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

          Comment


          • #6
            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.

            Comment


            • #7
              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, 11:52 AM. Reason: make url clickable

              Comment

              Working...
              X