NaturalIdResolutionCache not correctly filled on first persist when @GeneratedValue-@Id

Description

Employee.java

NaturalIdTest1.java

NaturalIdTest2.java

The NaturalIdTest1 will issue an SQL statement for the find-by-natural-id-query; the NaturalIdTest2 does not.

Put a breakpoint into NaturalIdResolutionCache#cache(Serializable, Object[]) and watch the pk-parameter to be null on the first invocation and not null on the second invocation.

If the @Id-field is not @GeneratedValue, the first invocation of NaturalIdResolutionCache#cache will be already correct.

Environment

None

Assignee

Brett Meyer

Reporter

Frank Schwarz

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure