HHH-13651 NPE on flushing when ElementCollection field contains null element
(cherry picked from commit 2808a75d5c
)
This commit is contained in:
parent
0115b89fe1
commit
bdf0a89f82
|
@ -202,11 +202,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();
|
||||
|
|
Loading…
Reference in New Issue