MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
djwaters
Post subject: Problems adding children.  PostPosted: Apr 08, 2010 - 02:56 PM
Registered Member
Registered Member


Joined: Jan 25, 2008
Posts: 36

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;
}
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
hhogan
Post subject:   PostPosted: Apr 08, 2010 - 05:43 PM
Registered Member
Registered Member


Joined: Apr 14, 2008
Posts: 104

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

Code:
@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;
}
 
 View user's profile Send private message  
Reply with quote Back to top
djwaters
Post subject:   PostPosted: Apr 12, 2010 - 07:01 PM
Registered Member
Registered Member


Joined: Jan 25, 2008
Posts: 36

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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits