in core/src/main/java/org/hibernate/ogm/model/spi/Association.java [174:209]
public Iterable<RowKey> getKeys() {
if ( currentState.isEmpty() ) {
if ( cleared ) {
// if the association has been cleared and the currentState is empty, we consider that there are no rows.
return Collections.emptyList();
}
else {
// otherwise, the snapshot rows are the current ones
return snapshot.getRowKeys();
}
}
else {
// It may be a bit too large in case of removals, but that's fine for now
Set<RowKey> keys = CollectionHelper.newLinkedHashSet( cleared ? currentState.size() : snapshot.size() + currentState.size() );
if ( !cleared ) {
// we add the snapshot RowKeys only if the association has not been cleared
for ( RowKey rowKey : snapshot.getRowKeys() ) {
keys.add( rowKey );
}
}
for ( Map.Entry<RowKey,AssociationOperation> op : currentState.entrySet() ) {
switch ( op.getValue().getType() ) {
case PUT:
keys.add( op.getKey() );
break;
case REMOVE:
keys.remove( op.getKey() );
break;
}
}
return keys;
}
}