| If the plan was to bind strategies to regions 1:1, why would Region and RegionAccessStrategy have been created as separate concepts? Given where we are now I think there are two sensible courses of action.
- In the released versions hibernate-core itself should throw if a user configures entities with incompatible cache data descriptions such that they share a region. buildAccessStrategy should be called once per entity with the entity's access type. If that means multiple calls on the same region then that is fine (as far as hibernate-core is concerned). If a given caching provider module can't handle one of these calls (because it can't support multiple unrelated entities in one region, or can't support multiple types of access strategy in the same region, or because the moon is waxing gibbous, etc.) then the provider can throw it's own exception.
- In a future version if it's decided that not sharing regions between disjoint types as determined by CDD or AccessStrategy, (or some unknown future mechanism) is something that should become a hibernate-core restriction then we should redefine the caching SPI in a manner that reflects that (as an example we could eliminate the distinction between Region and RegionAccessStrategy), and then all implementations can perceive the new constraints directly by examining the type system rather than having to closely inspect (and continuously monitor) the calling code.
|