Skip to content

HHH-20773 Resolve UNFETCHED_PROPERTY for initialized lazy fields during 2LC disassembly - #13168

Open
stalep wants to merge 1 commit into
hibernate:mainfrom
stalep:HHH-20773
Open

HHH-20773 Resolve UNFETCHED_PROPERTY for initialized lazy fields during 2LC disassembly#13168
stalep wants to merge 1 commit into
hibernate:mainfrom
stalep:HHH-20773

Conversation

@stalep

@stalep stalep commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

…ng 2LC disassembly

When a @immutable + @Cacheable entity has a @basic(fetch = FetchType.LAZY) field AND collection/entity associations (@manytomany, @manytoone), the lazy field is never served from the second-level cache.

Every access triggers initializeLazyPropertiesFromDatastore a DB round-trip, even though @Cache(includeLazy=true) is the default and isLazyPropertiesCacheable() returns true.

For @immutable entities with @Cache(includeLazy=true) (the default), the lazy field value should be included in the StandardCacheEntryImpl.disassembledState when the entity is first persisted (since the value is set by the application and can never change). Subsequent loads from the 2LC should serve the value from cache without a DB round-trip.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.



Please make sure that the following tasks are completed:
Tasks specific to HHH-20773 (Improvement):

  • Add tests for feature/improvement
  • Update documentation as relevant: javadoc for changed API, documentation/src/main/asciidoc/userguide for all features, documentation/src/main/asciidoc/introduction for main features, links from existing documentation
  • Add entries as relevant to migration-guide.adoc (breaking changes) and whats-new.adoc (new features/improvements)

https://hibernate.atlassian.net/browse/HHH-20773

@hibernate-github-bot

hibernate-github-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@stalep stalep changed the title HHH-20773 Resolve UNFETCHED_PROPERTY for initialized lazy fields duri… HHH-20773 Resolve UNFETCHED_PROPERTY for initialized lazy fields during 2LC disassembly Aug 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
45.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant