Skip to content

Commit 69735f8

Browse files
committed
HHH-18885 Introduce DelayedOperation.getAddedEntry() for maps
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.
1 parent 00d446f commit 69735f8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

hibernate-core/src/main/java/org/hibernate/collection/spi/AbstractPersistentCollection.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ public final Iterator<E> queuedAdditionIterator() {
852852

853853
@Override
854854
public E next() {
855-
return operationQueue.get( index++ ).getAddedInstance();
855+
return operationQueue.get( index++ ).getAddedEntry();
856856
}
857857

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

12281228
E getAddedInstance();
1229+
1230+
default E getAddedEntry() {
1231+
return getAddedInstance();
1232+
}
12291233

12301234
E getOrphan();
12311235
}

hibernate-core/src/main/java/org/hibernate/collection/spi/PersistentMap.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,12 @@ protected AbstractMapValueDelayedOperation(K index, E addedValue, E orphan) {
526526
protected final K getIndex() {
527527
return index;
528528
}
529+
530+
@Override
531+
public E getAddedEntry() {
532+
// The (E) cast is very hacky because E is not Map.Entry but we need it to conform to PersistentCollection.queuedAdditionIterator()
533+
return (E) Map.entry( getIndex(), getAddedInstance() );
534+
}
529535
}
530536

531537
final class Put extends AbstractMapValueDelayedOperation {

0 commit comments

Comments
 (0)