I am using ehcache-spring-annotations to cache the List returned from a service method:
@Cacheable(cacheName = "categoriesCache")
public List<Category> findAllCategories()
Then later in my JSP, I iterate though the list of Category parent objects to get a list of Subcategories children.
<c:forEach var="subcategory" items="${category.subcategories}">
Is there a configuration setting I could use to also have the subcategories (children) be cached by default? I suppose, I could create a new service method getSubcategories(CategoryID) and set that as @Cacheable. Then instead of calling the category.subcategories , I could call the new method.
Thanks.
Are you actually getting an error for the jsp call?
The way caching usually works is that every Category object in the List will be cached. If these objects have attributes they will be cached as well (as part of the Category object in the key-object cache). As long as findAllCategories() returns the children as part of Category, they should be cached as well.