Quote:
Do i need to add @mutable annotation to be object?
No, it's the other way around: your entities are mutable, it's the cache which needs to be declared read-write but is read-only.
About your previous question, Hibernate is very careful in not enabling caches if you're not really sure and aware of the subtle consequences. So enabling caching for a single-object load requires:
* to enable the second level cache globally (and configure it)
* to enable caching on the entity
Both need to be true, or it won't use it.
To cache queries you have to go beyond that:
* enable query caching globally
* specify on the query that it's cachable
Even more, when you change any object which might affect the query result, the results are evicted from cache.
Example:
1) list all users --> need to load from database
2) lists all users --> will use cache
3) insert a new user -->invalidates the query cache for "list all users" query
4) lists all users --> needs to query the database again
This is all needed to have transactions work correctly, and use caches.
Hope this is useful to verify your cache usage: be sure to enable all options and to not invalidate the entry.