facebook

Problems adding children.

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #307475 Reply

    Dennis
    Participant

    This is related to my previous post. I’m getting errors when adding children to Customer. I’ve fixed them, but should I have to? I reported these issues before the GA.

    Here is my fix (I commented out the unnecessary lines) At least I think they are necessary, and, in fact, cause the error. The first store of sapcustsalesarea fails due to a null sapCustomer. As I said, this is the same problem I reported weeks ago.

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public SapCustomer saveSapCustomerSapCustSalesarea(String customerNum, SapCustSalesarea sapcustsalesarea) {
    SapCustomer sapcustomer = sapCustomerDAO.findSapCustomerByPrimaryKey(customerNum, -1, -1);

    //sapcustsalesarea = sapCustSalesareaDAO.store(sapcustsalesarea);
    //sapCustSalesareaDAO.flush();

    sapcustsalesarea.setSapCustomer(sapcustomer);
    //sapcustomer.getSapCustSalesareas().add(sapcustsalesarea);

    sapcustsalesarea = sapCustSalesareaDAO.store(sapcustsalesarea);
    sapCustSalesareaDAO.flush();

    //sapcustomer = sapCustomerDAO.store(sapcustomer);
    //sapCustomerDAO.flush();

    return sapcustomer;
    }

    #307482 Reply

    Heflin Hogan
    Member

    I went back and reviewed the previous thread, and I noticed that we did not let you know that we do have an issue logged for this. It did not get in before the GA code freeze, but it is scheduled for the next release.

    What has happened is that we’ve generated a couple of extraneous lines that in this case try to store the child before it has been associated with its parent, which results in the not null error you are getting.

    I don’t think you need to comment out as much as you have. All you should need to eliminate is the first 2 store and flush lines, as below. Please let me know if that is not the case.

    Regards,
    Heflin

    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public SapCustomer saveSapCustomerSapCustSalesarea(String customerNum, SapCustSalesarea sapcustsalesarea) {
    SapCustomer sapcustomer = sapCustomerDAO.findSapCustomerByPrimaryKey(customerNum, -1, -1);
    
    //sapcustsalesarea = sapCustSalesareaDAO.store(sapcustsalesarea);
    //sapCustSalesareaDAO.flush();
    
    sapcustsalesarea.setSapCustomer(sapcustomer);
    sapcustomer.getSapCustSalesareas().add(sapcustsalesarea);
    
    sapcustsalesarea = sapCustSalesareaDAO.store(sapcustsalesarea);
    sapCustSalesareaDAO.flush();
    
    sapcustomer = sapCustomerDAO.store(sapcustomer);
    sapCustomerDAO.flush();
    
    return sapcustomer;
    }
    #307575 Reply

    Dennis
    Participant

    I guess I don’t understand why you would execute another save of sapcustomer in this case. I’m not sure exactly what’s happening in your store() method in AbstractJpaDao, as I haven’t looked at its source.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Problems adding children.

You must be logged in to post in the forum log in