Class AuthCollectionsCacheContributor

java.lang.Object
com.axelor.db.hibernate.contributor.AuthCollectionsCacheContributor
All Implemented Interfaces:
AdditionalMappingContributor

public class AuthCollectionsCacheContributor extends Object implements AdditionalMappingContributor
Enables the second-level collection cache (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.