saving new entity with immutable natural id leads to NPE

Description

checkNaturalId in DefaultFlushEntityEventListener gets a snapshot via getNaturalIdSnapshot if the loaded variable is null. The result of that is null if nothing exists in the database yet. A couple of lines down the variable is used without null check --> NPE.

still there in trunk as well.

Activity

Steve EbersoleMarch 21, 2011 at 7:06 PM

Bulk closing stale resolved issues

Michael KoppMay 6, 2009 at 9:17 PM

No . I saw it while stumbling over the other bug.

see line 87.
84 : Object loadedVal;
85 : if ( loaded == null ) {
86 : if ( snapshot == null) {
87 : snapshot = session.getPersistenceContext().getNaturalIdSnapshot( entry.getId(), persister );
88 : }
89 : loadedVal = snapshot[i];

line 89 will access the snapshot array even if nothing is found in the database --> NPE

Diego PlentzMay 6, 2009 at 7:39 PM

You could provide the stacktrace? By the description it looks like the same code point to me. Thanks

Michael KoppMay 6, 2009 at 7:30 PM

This is not really a duplicate of HHH-3884. 3884 is happening with a mutable and this one with and immutable natural id. and it is a different place in the code

Duplicate

Details

Assignee

Reporter

Affects versions

Priority

Created April 29, 2009 at 10:09 AM
Updated March 21, 2011 at 7:06 PM
Resolved May 5, 2009 at 6:16 PM