Skip to content

Conversation

@beikov
Copy link
Member

@beikov beikov commented Aug 28, 2025

[Please describe here what your change is about]


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19725
https://hibernate.atlassian.net/browse/HHH-18217

@gavinking
Copy link
Member

gavinking commented Aug 30, 2025

Thanks for working on this one, Christian.

One doubt I have is: there are two different cases here:

  • management of secondary table updates (the original purpose of this code)
  • upserts of primary tables (my abuse of Steve's original code)

Looking at these changes I can't clearly see where the difference between the two usages is manifest. It might be enough to just add a comment or something, but I would definitely like maintainers to have some warning about this subtlety. WDYT?

@beikov
Copy link
Member Author

beikov commented Nov 27, 2025

OptionalTableUpdateOperation and DeleteOrUpsertOperation both implement insert-update-or-delete semantics and the information to decide on the action comes from the passed ValuesAnalysis#getTablesWithNonNullValues().

When a table has non-null values, it will upsert, otherwise it will be deleted. To force upsert semantics, MergeCoordinator#analyzeUpdateValues makes sure to adapt the ValuesAnalysis to avoid deleting rows from optional tables when it would end up with just null values and instead always do an upsert.

I'm not sure where the best place for such a comment would be, but I added a summary of what I described here already to MergeCoordinator#analyzeUpdateValues. Let me know if you think that we need more comments and where you think they'd be appropriate.

@beikov beikov merged commit eacb836 into hibernate:main Dec 1, 2025
28 checks passed
@beikov beikov deleted the HHH-18217 branch December 1, 2025 13:30
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.

3 participants