I have the following entity
Code:
class Parent {
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE,
region = "com.foo.DefaultCollectionCache")
protected Set<ChildrenEntity> children =
new HashSet<ChildrenEntity>();
}
The cached collection was not activated previously and everything runs fine. Since we activated collection cache we have failure in our unit test in the tearDown.
We have a unit test that creates a Parent (A) then create a child (B) and associated B to A (setParent(A))
In the teardown we remove first B then we try to remove A. With caching activated, we get
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.foo.ChildrenEntity#8aacfe031fefbbde011fefd365d20068]
I suppose that Hibernate is trying to remove the orphean but a legitimate call to remove was done just before and it's working fine without the cache.
Any idea?