I'm having an issue with Hibernate Cache as it relates to collections.
I have an entity, which is cached. The entity has a collection, and the collection is also cached. The entity on the other side of the collection, likewise, is cached.
The issue arises when I try to add an object to the collection. I make sure to add the relationship on both sides. That is, I add the child, persist it, and then add the child to the parent's collection. Hibernate logs a "pre-invalidating" and "invalidating" message on the relationship's table.
However, if I reload the parent entity, the child is not in the collection. If I restart the server to clear the cache, the child will be in the collection as expected.
The issue occurs on a delete, as well. That is, the child will still be in the collection after reloading the entity, although it is no longer in the database.
Removing caching on the collection OR on the parent itself will cause the issue to go away.
What might be causing this problem?
|