Making ehcache read-write for test code and read-only for production code
- by Rick
I would like to annotate many of my Hibernate entities that contain reference data and/or configuration data with
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
However, my JUnit tests are setting up and tearing down some of this reference/configuration data using the Hibernate entities.
Is there a recommended way of having entities be read-write during test setup and teardown but read-only for production code?
Two of my immediate thoughts for non-ideal workarounds are:
Using NONSTRICT_READ_WRITE, but I am not sure what the hidden downsides are.
Creating subclassed entities in my test code to override the read-only cache annotation.
Any recommendations on the cleanest way to handle this?
(Note: Project uses maven.)