@FetchProfile not working with @OneToOne(mappedBy=...) properties

Description

Sample entities:

When defining a FetchProfile for entity Address and association customer (which has mappedBy), the VerifyFetchProfileReferenceSecondPass will fail with the following exception:

org.hibernate.MappingException: property [customer] not found on entity [org.hibernate.test.annotations.fetchprofile.Address]

The problem seems to be that OneToOne associations with mappedBy are added via OneToOneSecondPass but this second pass will be added after the VerifyFetchProfileReferenceSecondPass because the FetchProfiles are added quite early in the AnnotationBinder.bindClass method. I think the FetchProfiles need to be added at the end of the bindClass and/or after the bindClass has finished.

Additionally when defining FetchProfiles via package-info in the (same?) package the same exception occurs. The problem here seems to be that package-info is processed before the entity hierarchy. I think the bindFetchProfiles for all packages should be called after all entity hierarchies have been initialised.

Environment

None

Activity

Show:
Sanne Grinovero
July 22, 2020, 12:59 PM

Excellent contribution, many thanks ! Merged

Assignee

Oliver Saggau

Reporter

Oliver Saggau

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure