Unmodifiable - Improved read only immutable entity beans / graphs by rbygrave · Pull Request #3570 · ebean-orm/ebean

added 5 commits

October 24, 2024 16:02
…LazyLoad=true]

Although this is ok, makes me think that another option is just to have query.setReadOnly(true)
to mean ... readOnly + disableLazyLoad + error reading unloaded property or collection. As in,
readOnly true without these extra things does not that good [as in the existing readOnly does
not seem very good/safe/useful to use].
… existing use of IllegalStateException

- Adds new exceptions UnloadedPropertyException and UnmodifiableEntityException
- Change InterceptReadOnly to use these exception instead of IllegalStateException
- Change collections BeanSet, BeanList, BeanMap from using IllegalStateException to UnsupportedOperationException [to bring these in line with JDK unmodifiable collections]
Add unmodified to DefaultOrmQuery query plan description
Fix incorrect merge conflict

@rbygrave rbygrave changed the title Improved read only immutable Unmodifiable - Improved read only immutable entity beans / graphs

Feb 21, 2025

rPraml

@rbygrave

@rbygrave

Noting that the freeze needs to occur after secondary queries have executed

@rbygrave

- Query Cache now holds unmodifiable collections
- Can no longer have readOnly=false with queryCache=true
- Reference beans now also honor unmodifiable
- Effectively no longer does bean cache lookup for reference beans (which it defaulted to when cacheSharableBeans true, e.g. Country entity bean)

rPraml

@rbygrave

rbygrave

@rbygrave

…n also be unmodifiable

Entities without *any* relationships can support "sharable instances" with bean caching. This change restores that and uses unmodifiable instances (rather than the old ReadOnly).

Currently, for a query to get shared instances it now needs to explicitly use setUnmodifiable(true) where as before it defaulted to shared instances so that is a behaviour change.

Additionally, bean cache queries were not honouring setUnmodifiable(true) and with these changes they now do.

@rbygrave

@rbygrave

rPraml

@rbygrave

@rbygrave

…utable-part2

Remove readOnly, migrate to unmodifiable (or use normal mutable)

@rbygrave

And:

LazyInitialisationException extends BeanAccessException ...
UnmodifiableEntityException extends BeanAccessException ...