OgmEntityPersister / EntityAssociationUpdater is throwing an exception: OGM000082: The entity at the inverse side of the association cannot be found in the session for the use case below, using Redis with the default IN_ENTITY Association Storage. The referenced entities in the exception are absolutely in the session. I believe this may be related to an entity with self-referencing parent-child relationships. Category Entity
@Id
private String id;
private String name;
private byte sortOrder;
@ManyToOne
private Category parentCategory;
@OneToMany(mappedBy = "parentCategory", fetch = FetchType.EAGER)
private SortedSet<Category> subcategories;
EJB Method
public void reorderSubcategories(Category category) {
Category persistedCategory = entityManager.find(Category.class, category.getId());
List<Category> subcategories = new ArrayList<>(category.getSubcategories());
for (Category subcategory : persistedCategory.getSubcategories()) {
subcategory.setSortOrder((byte) subcategories.indexOf(subcategory));
}
}
A specific example of the exception message is: OGM000082: The entity at the inverse side of the association 'subcategories' cannot be found in the session: EntityKey(Category) [id=4b4c7205-c893-43ec-96a2-34c8d1f87cd6] In this case, the entity with id=4b4c7205-c893-43ec-96a2-34c8d1f87cd6 is the Category passed to the EJB method and parentCategory to all subcategories. |