Kimble
Kimble

Reputation: 7554

How to invalidate / refresh a domain instance association?

There is a bug in Grails preventing me from using removeFrom* when the node I'm trying to remove is extending the collection type. Removing the node directly from the association won't update the second level cache.

A hasMany B

Is there any way to manually invalidate or force a reload on an association cache? Invoking refresh() on the many side didn't do the trick.

Upvotes: 1

Views: 590

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570355

If you have access to the SessionFactory instance, you could use evictCollection:

sessionFactory.evictCollection("Cat.kittens", catId); //evict a particular collection of kittens
sessionFactory.evictCollection("Cat.kittens"); //evict all kitten collections

Upvotes: 3

Related Questions