Hello together,
I use Hibernate 3.6 and Im pretty new to it. Im interested in using the 2nd Level Cache for it and Ive got various questions about it. It would be great if someone could answer them:
1. Is it correct that the 1st and 2nd Level Cache only cache objects which are loaded/stored/changed by Primary Key?
2. What about using Joins (which maybe not exclusively use the PK to request Data) - can the 1st and 2nd Level Cache be used for them?
3. What about the other requests which are not using the PK? I mean often there exist a lot of them, so I dont really understand why its not possible to use Caching for them (beside from Query Caching)
4. What would you say: when does it make sense to use the 2nd level cache? of course when Ive got a lot of database operations, but I think that data which is changed a lot(!!) shouldnt be cached, because synchronising the cache with the database does also decrease the performance. Thats why I think 2nd Level Cache should be only used for data for which more Read-Operations then Write-Operations are done. What do you think about that?
5. I read that for each table a CacheConcurrencyStrategy can be set, which influences the behaviour of hibernate of how data should be cached (and invalidated). Is that correct?
6. What about the CacheMode? It can be (additional to the CacheConcurrenyStrategy) set for the Hibernate-Session itself, so that it tells the Hibernate-Session if it should use the 2nd Level Cache or not? What sense does this make, when the EhCache is already configured for every table (to be used or not and in which way (only read, read-write and so on) Why should I additional say then "the session shall not write in the 2nd Level Cache, but read from it"? Sorry, I may be a little bit stupid, but could someone explain this maybe with a small example to me? that would be great :-)
Thanks a lot for your help!! :-)
|