Experimental Feature - Freeze and detach beans (and attach) #3317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Frozen beans as ReadOnly + Unmodifiable collections
Add Transaction.freezeAndDetach() returning FrozenBeans
Add Transaction.attach( FrozenBeans )
InterceptReadOnly now supports lazy loading
Query.setReadOnly(true) now uses InterceptReadOnly [when it used to ALSO require Query.setDisableLazyLoading(true)}
Add EntityBeanIntercept.errorOnLazyLoad (such that lazy loading on frozen bean is an error)
BeanList, BeanSet, BeanMap are now freezable
ModifyAwareList Set and Map are now freezable
Adds FrozenBeans [marker] interface for the frozen and detached beans [which can then be attached to other transactions and used as cached/frozen beans to seed the persistence context]
Expected use case
For performance reasons as a "caching mechanism" where there is good value in using unmodifable beans with potentially a significant amount of relationships and related data that is all infrequently changing.
These beans that are cached and used will often be graphs of related objects and represent some relatively infrequently changing "meta data".
Building frozen beans -
freezeAndDetach()
Using frozen beans -
attach()