We are creating a web application utilizing a tree-based datastructure. We want this datastructure to be cached by EhCahce to reduce load to our database. Each node object contains a list of children as well as a parent. We have been struggling to get the integration between Hibernate and EhCache working with this setup. It seems as though the entity has already been constructed with all its children, new queries are run through the database in order to re-populate the list of children when we get the list back from the cache. After poking around to figure out how it all works, I found that Hibernate puts entities going to the cache in its own object containing serialized versions of all its fields. This object does not contain links to either the list of children or the parent. By placing the entities into the cache manually, the object is preserved as is, and what you take out contain both these fields as they should be. We have no need to serialize the objects, as we are not going to use distributed cache. My question is: Am I missing some setting of some sort, or is this as designed?
|