If the object was updated outside of Hibernate, then after reading the previously recorded (in this session) data, we get obsolete values ​​from cache level 1?

  • of course, because hibernate does not have any information about the state of the object to invalidate the cache. - Artem Konovalov
  • @ArtemKonovalov offtopic. Why do you need a level 2 cache? As I understand it, it allows you to cache data at the session factory level, that is, wider than during the session. Maybe even why? I want a vital example - voipp
  • here about caches izebit.ru/2015/12/hibernate.html In short, the second level applies to all sessions. For example, if you have a multi-threaded application, then you hardly make sure that all threads work with one session, and then the second-level cache helps. - Artem Konovalov
  • @ArtemKonovalov and why the threads do not work well with one session? I can not give a simple example against this - voipp
  • OK, what is a session? This is an object associated with some kind of data that goes to the database. Fixed it. We have threads, there are calls to the database. If each thread simply would immediately throw off changes to the database, it would be ok. But they can open transactions. Those. the data is simply not flush in the database, but is stored in this session, before the commit. Now the question is, how will transactions from different threads working in one session behave? Right, it is not clear how. - Artem Konovalov

0