-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
base: main
Are you sure you want to change the base?
Conversation
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.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default E getAddedEntry() { | |
default Object getAddedEntry() { |
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() ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
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