org.hibernate.StaleStateException
Is thrown sometimes (not consistent) in unit test case.
The normal flow is:
- Create
- Update
- Delete
StaleStateException is thrown while executing delete operation.
The entity has child entities with one to many relationship:
<set name="child" cascade="delete, all,delete-orphan" inverse="true"
lazy="true">
<cache usage="nonstrict-read-write"/>
<key column="COLUMN"/>
<one-to-many class="CHILDClass"/>
</set>
And the cache strategy is "nonstrict-read-write"
Not sure of its issue due to second level cache, as the exception is not consistent. How to fix this issue and what extra details I need to check to fix this issue.