Skip to content

HHH-18885 Introduce DelayedOperation.getAddedEntry() for maps #10230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gtoison
Copy link
Contributor

@gtoison gtoison commented May 27, 2025

Same as #9331 minus the unit test (because extra lazy maps are gone in Hibernate 7), to keep branches aligned


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-18885

Extra lazy maps need to persist the added entry (key and value), not the
added value.
Let PersistentMap.AbstractMapValueDelayedOperation return the added
entry so
OneToManyPersister.writeIndex() can execute the queued operation.
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented May 27, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@@ -1226,6 +1226,10 @@ protected interface DelayedOperation<E> {
void operate();

E getAddedInstance();

default E getAddedEntry() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default E getAddedEntry() {
default Object getAddedEntry() {

Comment on lines 531 to 534
public E getAddedEntry() {
// The (E) cast is very hacky because E is not Map.Entry but we need it to conform to PersistentCollection.queuedAdditionIterator()
return (E) Map.entry( getIndex(), getAddedInstance() );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public E getAddedEntry() {
// The (E) cast is very hacky because E is not Map.Entry but we need it to conform to PersistentCollection.queuedAdditionIterator()
return (E) Map.entry( getIndex(), getAddedInstance() );
}
public Object getAddedEntry() {
return Map.entry( getIndex(), getAddedInstance() );
}

@@ -852,7 +852,7 @@ public final Iterator<E> queuedAdditionIterator() {

@Override
public E next() {
return operationQueue.get( index++ ).getAddedInstance();
return operationQueue.get( index++ ).getAddedEntry();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change org.hibernate.collection.spi.PersistentCollection#queuedAdditionIterator to return an Iterator<?>, and this method to return Object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the change to return an Iterator<?>

For maps the iterator operates over a collection of Map.Entry
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