Hibernate: Clean collection's 2nd level cache while cascade delete items

前端 未结 3 544
梦谈多话
梦谈多话 2021-02-08 19:04

I have a problem Hibernate does not update 2nd level cache for a collection of items which are subject of cascade removal.

Details

Assume we have an object Par

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 19:07

    Usually Hibernate need a politically incorrect refresh of the object to reload the cahe.

    An important thing is how that EhCache handles the lazy properties. I found that the lazy attribute of the collection is not set, the cahe doesn't refresh the objects.

    In your case, If the Humans set of the humanity attribute is set to lazy = true (default option), ehcache doesn't refresh it if the object. Try to set the lazy attribute of the humans and children collections to false.

提交回复
热议问题