Skip to content

Commit a585756

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 fc353b2 commit a585756

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
@@ -849,7 +849,7 @@ public final Iterator<E> queuedAdditionIterator() {
849849

850850
@Override
851851
public E next() {
852-
return operationQueue.get( index++ ).getAddedInstance();
852+
return operationQueue.get( index++ ).getAddedEntry();
853853
}
854854

855855
@Override
@@ -1204,6 +1204,10 @@ protected interface DelayedOperation<E> {
12041204
void operate();
12051205

12061206
E getAddedInstance();
1207+
1208+
default E getAddedEntry() {
1209+
return getAddedInstance();
1210+
}
12071211

12081212
E getOrphan();
12091213
}

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
@@ -528,6 +528,12 @@ protected AbstractMapValueDelayedOperation(K index, E addedValue, E orphan) {
528528
protected final K getIndex() {
529529
return index;
530530
}
531+
532+
@Override
533+
public E getAddedEntry() {
534+
// The (E) cast is very hacky because E is not Map.Entry but we need it to conform to PersistentCollection.queuedAdditionIterator()
535+
return (E) Map.entry( getIndex(), getAddedInstance() );
536+
}
531537
}
532538

533539
final class Put extends AbstractMapValueDelayedOperation {

0 commit comments

Comments
 (0)