Reputation: 4483
My DataSource Config:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
i have an entity named Category that can have one or more Categories (children)
class Category{
int ordering
static hasMany = [categories: Category]
static mapping = {
categories(sort: "ordering", order: "asc")
sort "ordering"
cache usage: 'nonstrict-read-write'
categories cache: 'nonstrict-read-write'
}
When i change a property from the admin page, lets say the ordering property from a category instance, that change is not reflected from the association to the parent category, so the assoc collection has the old property for the altered child. I tried to remove this:
categories cache: 'nonstrict-read-write'
and then the categories assoc is always up to dated.
How can i ensure that every time i update a category instance, the categories assoc for the parent category will be informed with the changes? Shouldnt be worked like this by default??
Upvotes: 2
Views: 238
Reputation: 4483
ok i found it! i had to evict the entire collection like this: sessionFactory.evictCollection(Category.class.name + '.categories')
Upvotes: 1