Skip to content

Commit bd63ded

Browse files
gtoisonmbellade
authored andcommitted
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 8fa64ba commit bd63ded

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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,8 @@ public final Iterator<E> queuedAdditionIterator() {
849849

850850
@Override
851851
public E next() {
852-
return operationQueue.get( index++ ).getAddedInstance();
852+
//noinspection unchecked
853+
return (E) operationQueue.get( index++ ).getAddedEntry();
853854
}
854855

855856
@Override
@@ -1204,6 +1205,10 @@ protected interface DelayedOperation<E> {
12041205
void operate();
12051206

12061207
E getAddedInstance();
1208+
1209+
default Object getAddedEntry() {
1210+
return getAddedInstance();
1211+
}
12071212

12081213
E getOrphan();
12091214
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,11 @@ protected AbstractMapValueDelayedOperation(K index, E addedValue, E orphan) {
528528
protected final K getIndex() {
529529
return index;
530530
}
531+
532+
@Override
533+
public Object getAddedEntry() {
534+
return Map.entry( getIndex(), getAddedInstance() );
535+
}
531536
}
532537

533538
final class Put extends AbstractMapValueDelayedOperation {

0 commit comments

Comments
 (0)