Legacy Criteria API: could not resolve Property on One-To-One @PrimaryJoinColumn with hibernate

Description

Criteria API code that searches via associated Entity ID does not work in Hibernate 5.4.1. while it still worked in Hibernate 5.2.18,

This happens if the association is an optional OneToOne mapped with PrimaryKeyJoinColumn. If the association is mapped optional=false the query still works.

The cause seem to be the commit https://github.com/hibernate/hibernate-orm/commit/2bfe30009c15ea59c587d11714d4be78b14f9ad9 and the partial revert in https://github.com/hibernate/hibernate-orm/commit/8535adc05736e9ae93d818d9aff25bf9255a1bbd

The attached test case works with 5.2.18, but fails in 5.4.1.

Environment

None

Assignee

Unassigned

Reporter

Christian Fraenkel

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.18
5.3.9

Components

Affects versions

Priority

Major
Configure