Sometime getting org.hibernate.StaleStateException when calling delete after update

290 Views Asked by At
org.hibernate.StaleStateException 

Is thrown sometimes (not consistent) in unit test case.

The normal flow is:

  1. Create
  2. Update
  3. 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.

0

There are 0 best solutions below