Is it possible to cache only some instances of an entity? For example if I have a CMS (Content management system) with a dynamic menu. Then I would have a MenuItem entity, which I would like to cache, because the menu items don't change much and are needed for every page. A MenuItem would have a property to the Page entity it is linking to. What I would like to do is cache just those pages that are referenced from a MenuItem.
A tried making a subentity of Page and only add an org.hibernate.annotations.Cache annotation to the subentity. The idea was that the pages referenced from MenuItems would be of this subentity. However this did not work, because subentities always have the same caching strategy as their root entity. So is there perhaps another way of specifying which instances you would like to cache? For example there is a way to evict specific instances from the cache, so maybe you can add specific instances to the cache and then tell Hibernate to stop automatic caching for that entity? Sadly I could not find anything like this.
Thanks
|