Skip to content

Commit aec8baa

Browse files
committed
HHH-18885 let queuedAdditionIterator() return Iterator<?>
For maps the iterator operates over a collection of Map.Entry
1 parent 69735f8 commit aec8baa

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,13 +845,13 @@ public final boolean hasQueuedOperations() {
845845
}
846846

847847
@Override
848-
public final Iterator<E> queuedAdditionIterator() {
848+
public final Iterator<?> queuedAdditionIterator() {
849849
if ( hasQueuedOperations() ) {
850850
return new Iterator<>() {
851851
private int index;
852852

853853
@Override
854-
public E next() {
854+
public Object next() {
855855
return operationQueue.get( index++ ).getAddedEntry();
856856
}
857857

@@ -1226,8 +1226,8 @@ protected interface DelayedOperation<E> {
12261226
void operate();
12271227

12281228
E getAddedInstance();
1229-
1230-
default E getAddedEntry() {
1229+
1230+
default Object getAddedEntry() {
12311231
return getAddedInstance();
12321232
}
12331233

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ default boolean needsUpdating(
388388
*
389389
* @return The iterator
390390
*/
391-
Iterator<E> queuedAdditionIterator();
391+
Iterator<?> queuedAdditionIterator();
392392

393393
/**
394394
* Get the "queued" orphans

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,10 @@ protected AbstractMapValueDelayedOperation(K index, E addedValue, E orphan) {
526526
protected final K getIndex() {
527527
return index;
528528
}
529-
529+
530530
@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() );
531+
public Object getAddedEntry() {
532+
return Map.entry( getIndex(), getAddedInstance() );
534533
}
535534
}
536535

0 commit comments

Comments
 (0)