Non-optional, lazy @OneToOne( mappedBy = "..." ) attribute does not get initialized as a proxy

Description

Given the following mappings:

Assuming enhacement-as-proxy is enabled (hibernate.bytecode.allow_enhancement_as_proxy=true), when an Employer is loaded, Employer#employerInfo is not initialized as an enhanced proxy. It is lazily loaded when accessed.

Environment

None

Activity

Show:
Gail Badner
January 15, 2020, 11:18 PM
Edited

Removing text of comment because there was a mistake in the mapping. The mapping above has been corrected.

Gail Badner
January 16, 2020, 12:05 AM

I’ve pushed a test upstream that illustrates this issue. {{MapsIdProxyBidirectionalTest#testMappedByAssociation}} is marked {{FailureExpected}}.

 

Gail Badner
January 16, 2020, 12:55 AM
Edited

I see that the mappedBy association is excluded because of this code in {{EnhancementHelper#includeInBaseFetchGroup}}.

When this code commented out, the association gets eagerly loaded.

I think it should be possible to load the association as a proxy in the case where the opposite side of the association is annotated with {{@MapsId}} without any arguments. Same should be true when the opposite side of the association is annotated with {{@PrimaryKeyJoinColumns}} with all ID columns mapped.

In other cases, the {{EmployerInfo}} ID will not be known to {{Employer}}. It seems strange to leave this uninitialized (without a proxy) when enhancement-as-proxy is enabled, but I’m not sure of an alternative.

Gail Badner
January 16, 2020, 6:18 PM

I’ve changed this to an “Improvement” that applies to the case when bytecode enhancement is disabled as well.

Assignee

Unassigned

Reporter

Gail Badner

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure