Description of problem: When calling Category.deleteCategoryAndRemap() for a category to which related categories have been added with addRelatedCategory(), deletion of the "related categories" association fails with a "IllegalArgumentException: No such object" exception. Version-Release number of selected component (if applicable): 6.0 How reproducible: Always Steps to Reproduce: Replace the two category IDs in the attached JSP with actual values from your cat_categories table and try to run the JSP. Actual Results: java.lang.IllegalArgumentException: No such object: [com.arsdigita.categorization.com_arsdigita_categorization_Category:parents::com_arsdigita_categorization_Category:related::Link:{parents=[com.arsdigita.categorization.Category:{id=147}], related=[com.arsdigita.categorization.Category:{id=165}]}] at com.redhat.persistence.Session.fetchPropertyData(Session.java:787) at com.redhat.persistence.Session$1.onRole(Session.java:115) at com.redhat.persistence.metadata.Role.dispatch(Role.java:92) at com.redhat.persistence.Session.get(Session.java:113) at com.arsdigita.persistence.DataObjectImpl.get(DataObjectImpl.java:489) at com.arsdigita.persistence.DataObjectImpl.get(DataObjectImpl.java:200) at com.arsdigita.categorization.Category.deleteCategoryAndRemap(Category.java:923) Additional info: The cause for this error is the following while loop, which first deletes the association and then tries to retrieve attributes from the link object it has just deleted: while (cursor.next()) { DataObject link = cursor.getLink(); remove(RELATED_CATEGORIES, cursor.getDataObject()); if ("child".equals(link.get("relationType"))) { Category category = new Category(cursor.getDataObject()); parent.addChild(category); if (Boolean.TRUE.equals(link.get("isDefault"))) { category.setDefaultParentCategory(parent); } } } One way to fix this: while (cursor.next()) { DataObject link = cursor.getLink(); String relationType = (String)link.get("relationType"); Boolean isDefault = (Boolean)link.get("isDefault"); remove(RELATED_CATEGORIES, cursor.getDataObject()); if ("child".equals(relationType)) { Category category = new Category(cursor.getDataObject()); parent.addChild(category); if (Boolean.TRUE.equals(isDefault)) { category.setDefaultParentCategory(parent); } } }
Created attachment 94025 [details] JSP for reproducing the problem
Carsten: does your 35415 fix the problem, or does it need to be fixed some other way?
35415 fixes it.
Has this been integrated onto the Troika branch at all?
Integrated by Archit @35437