- This topic has 2 replies, 2 voices, and was last updated 14 years, 8 months ago by Dennis.
-
AuthorPosts
-
DennisParticipantThis 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;
}
Heflin HoganMemberI 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; }
DennisParticipantI 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.
-
AuthorPosts