HHH-13651 NPE on flushing when ElementCollection field contains null element

This commit is contained in:
Yosef Yona 2019-10-23 18:58:54 +03:00 committed by Sanne Grinovero
parent 97c300a6ad
commit 2808a75d5c
1 changed files with 15 additions and 1 deletions

View File

@ -199,11 +199,25 @@ public class PersistentBag extends AbstractPersistentCollection implements List
}
Map<Integer, List<Object>> map = new HashMap<>();
for (Object o : searchedBag) {
map.computeIfAbsent( elementType.getHashCode( o ), k -> new ArrayList<>() ).add( o );
map.computeIfAbsent( nullableHashCode(o , elementType), k -> new ArrayList<>() ).add( o );
}
return map;
}
/**
* @param o
* @param elementType
* @return the default elementType hashcode of the object o, or null if the object is null
*/
private Integer nullableHashCode(Object o, Type elementType) {
if ( o == null ) {
return null;
}
else {
return elementType.getHashCode( o );
}
}
@Override
public boolean isSnapshotEmpty(Serializable snapshot) {
return ( (Collection) snapshot ).isEmpty();