cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting error while using saveall instead of saving

Former Member
0 Likes
660

In our application we are updating order entrymodel in below way using modelservice.save

 final List entries = new ArrayList(cartModel.getEntries());
 for (int i = 0; i < entries.size(); i++) {
                 entries.get(i).setEntryNumber(Integer.valueOf(i));
                 modelService.save(entries.get(i));
             }


Bot now we have replaced the code in below way. Now sometimes we are getting exception ambiguous unique keys.

 final List entryList = new ArrayList();
                 for (int i = 0; i < entries.size(); i++) {
                     entries.get(i).setEntryNumber(Integer.valueOf(i));
                     entryList.add(entries.get(i));
                 }
                 modelService.saveAll(entryList);

exceptions:

 de.hybris.platform.servicelayer.interceptor.InterceptorException: 
 [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@5d68ac47]:ambiguous unique keys
  {entryNumber=1, order=CartModel (8833253376043@409)} for model CartEntryModel (9033849569324@5) - found 1 item(s) using the same keys

Could you please explain why we are getting the exceptions.

Accepted Solutions (0)

Answers (0)