Class AuthCollectionsCacheContributor
- All Implemented Interfaces:
AdditionalMappingContributor
READ_WRITE) for a curated set of
authentication association collections.
Marking an entity @Cacheable caches its own state but not its @OneToMany /
@ManyToMany collections; loading such a collection still issues a SQL query against the
link table on every access. The auth entities (User, Group, Role,
Permission) are all cacheable, so caching the ids stored by their read-frequently /
mutated-rarely association collections avoids that query.
This is the equivalent of annotating each collection with @Cache(usage =
CacheConcurrencyStrategy.READ_WRITE), applied during metadata bootstrap so it does not require a
change to the entity code generator. Only owning-side collections whose target entities are
themselves @Cacheable are listed, so the cached ids always resolve from the entity cache.
Each collection becomes its own L2 region named after the role (e.g.
com.axelor.auth.db.User.permissions); dedicated region blocks in application.conf size
and tune these to mirror their owning entity.
Registered via META-INF/services/org.hibernate.boot.spi.AdditionalMappingContributor.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontribute(AdditionalMappingContributions contributions, InFlightMetadataCollector metadata, ResourceStreamLocator resourceStreamLocator, MetadataBuildingContext buildingContext)
-
Constructor Details
-
AuthCollectionsCacheContributor
public AuthCollectionsCacheContributor()
-
-
Method Details
-
getContributorName
- Specified by:
getContributorNamein interfaceAdditionalMappingContributor
-
contribute
public void contribute(AdditionalMappingContributions contributions, InFlightMetadataCollector metadata, ResourceStreamLocator resourceStreamLocator, MetadataBuildingContext buildingContext) - Specified by:
contributein interfaceAdditionalMappingContributor
-