Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Conversation

@maxifridge
Copy link

@maxifridge maxifridge commented Sep 4, 2024

Implementation of #3695
Using retainAll() for Set and Map targets will minimize the amount of add/remove operations required for these types.
This limits side effects of removing preemptively all elements through clear() to non-Set Collections and Arrays.

A good example of why it is important (and the one that made me work on this issue) : when mapping to a Set property of a Hibernate-managed entity, calling clear() then addAll() effectively triggers requests for all deletions then all additions ; though because of the order of execution in Hibernate, only the newer elements are inserted, the others are deleted.

This limits side effects of removing preemptively all elements through clear() to non-Set Collections and Arrays.

A good example of why it is important is : when mapping to a Set property of a Hibernate-managed entity, calling clear() then addAll() effectively triggers requests for all deletions then all additions ; though because of the order of execution in Hiberante, only new elements are inserted.
@maxifridge maxifridge marked this pull request as draft September 4, 2024 09:38
@maxifridge maxifridge changed the title Use retainAll() for Set and Map instead of clear() #3695 Use retainAll() for Set and Map instead of clear() Sep 4, 2024
@maxifridge
Copy link
Author

This is still only a draft, it requires some cleaning/renaming, and certainly updating tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants