Question - What are the concurrency strategies available in hibernate?
Answer -
Concurrency strategies are the mediators responsible for storing and retrieving items from the cache. While enabling second-level cache, it is the responsibility of the developer to provide what strategy is to be implemented to decide for each persistent class and collection.
Following are the concurrency strategies that are used:
- Transactional: This is used in cases of updating data that most likely causes stale data and this prevention is most critical to the application.
- Read-Only: This is used when we don't want the data to be modified and can be used for reference data only.
- Read-Write: Here, data is mostly read and is used when the prevention of stale data is of critical importance.
- Non-strict-Read-Write: Using this strategy will ensure that there wouldn't be any consistency between the database and cache. This strategy can be used when the data can be modified and stale data is not of critical concern.