Hello! Seems that I found the problem. This happens due to what type hibernate will inject into Set
field. When you perform findAll
- Set
field will be injected as PersistenSet
type by default. This is shared reference between yours business logic side and dirty check mechanism
of hibernate. So when you
p.removeChildren(c);
parentRepo.save(p);
That operation triggers DefaultFlushEntityEventListener::dirtyCheck
. But due to final Object[] loadedState = entry.getLoadedState();
keeps shared reference
, for hibernate it looks like entity wasn’t change state of the entity. That’s why no validation error was occurred(but child entity will be deleted as expected by orphan removal)
PS
If you will change any field of the entity validation will be performed as expected