We're updating the issue view to help you get more done. 

NullPointerException after persisting null entity value as natural-Id

Description

This request is basically a reopening of HHH-7158.

story-line:
-Fixing of did successfully solve both attached testmethods, but only the first one was integrated into hibernate matrix tests.
-Fixing of did slightly change the way how natural-id-vales are compared, causing now testmethod2 fail again.

before HHH-7206:

1 2 3 4 5 6 // lengths have already been verified at this point for ( int i = 0; i < naturalIdTypes.length; i++ ) { if ( ! naturalIdTypes[i].isEqual( naturalIdValues[i], values[i] ) ) { return false; } }

after HHH-7206: (please notice now there has appeared persister.getFactory() as third parameter)

1 2 3 4 5 6 7 // lengths have already been verified at this point for ( int i = 0; i < naturalIdTypes.length; i++ ) { if ( ! naturalIdTypes[i].isEqual( values[i], otherValues[i], persister.getFactory() ) ) { return false; } } return true;

Proposed solutions:

Either revert back to using the isEqual method again with 2 parameters only,
or alternatevely make method
EntityType#isEqual(Object x, Object y, SessionFactoryImplementor factory)
stable against null x,y values as proposed in HHH-7158.
I don't know which one is the better solution, but both solution make the attached testcases go through without fails.

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Guenther Demetz

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.1.2

Priority

Minor