Hello, I'm using hibernate 3. I have a question about using second level caching. Currently I use ehcache. I have noticed that my objects are being recached pretty often when there are no changes to them. After some debugging, I found that each time I run a read-only query, any objects that are returned in the query somehow get re-put into the second level cache.
For example, List<Teacher> getAllTeachers(), invoking this method would get all Teacher instances placed into the second level cache even if they are already cached before. Does anyone know why? My suspicion is that the query loaded objects are cached into a different cache region, thus causing the duplication. But I haven't been able to find any information on that. Please help!
|