Hi! If I have an entity that contains an ArrayList, for example:
@Entity private static class ExampleEntity { private List<String> list = new ArrayList<>(); public void add(String item) { list.add(item); } public void removeIf(Predicate<String> predicate) { list.removeIf(predicate); } }
Then calling removeIf at all, even if it doesn't lead to the removal of any items from the list, still marks the object as dirty:
// Object state is: Nontransactional-Clean entity.removeIf(item -> false); // Object state is: Persistent-Dirty
When we use removeIf on a large number of objects, for which only a small % actually causes a removal of any items, it significantly slows down the commit. We have to work around it either by replacing removeIf with an Iterator, or by having an additional check if anything in the list would match the predicate before calling removeIf.
Would it be possible to mark the object as dirty only if the call to removeIf actually modifies it? Thanks.