Skip to content

Commit

Permalink
HHH-13651 NPE on flushing when ElementCollection field contains null …
Browse files Browse the repository at this point in the history
…element
  • Loading branch information
Yosef Yona authored and Sanne committed Oct 24, 2019
1 parent 97c300a commit 2808a75
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -199,11 +199,25 @@ private Map<Integer, List<Object>> groupByEqualityHash(List<Object> searchedBag,
}
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();
Expand Down

0 comments on commit 2808a75

Please sign in to comment.