Hibernate is new here.
As I understand it, the first level cache is only available if the session is open. When the session is closed, all cached objects in the first level are unloaded / deleted. Is it correct?
I have a simple CRUD application developed in Java using the Hibernate platform. And each time my application launches, downloads, and executes its first request operation, the execution time is usually longer than subsequent request operations. The first request usually takes 17 ms to complete, and the next 1-2 ms.
My question is, is this Hibernate behavior at the beginning of the application? Are data loaded from the first query operation stored in the cache? (Definitely not a session cache, because after completing my first request operation, the session closes right after that) Does the load affect the load?
I really don't know where to start, as the Hibernate documentation did not cover this. Correct me if I am wrong.
I appreciate any help since I really don't know where to start reading about it.
EDIT: For more information, see sleep statistics for the first and second query operations:
Firstly:
100222 nanoseconds spent acquiring 1 JDBC connections; 0 nanoseconds spent releasing 0 JDBC connections; 23238430 nanoseconds spent preparing 3 JDBC statements; 8333256 nanoseconds spent executing 3 JDBC statements; 0 nanoseconds spent executing 0 JDBC batches; 0 nanoseconds spent performing 0 L2C puts; 0 nanoseconds spent performing 0 L2C hits; 0 nanoseconds spent performing 0 L2C misses; 40215588 nanoseconds spent executing 1 flushes (flushing a total of 3 entities and 3 collections); 135213 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)
Secondly:
168597 nanoseconds spent acquiring 1 JDBC connections; 0 nanoseconds spent releasing 0 JDBC connections; 2332976 nanoseconds spent preparing 3 JDBC statements; 6427565 nanoseconds spent executing 3 JDBC statements; 0 nanoseconds spent executing 0 JDBC batches; 0 nanoseconds spent performing 0 L2C puts; 0 nanoseconds spent performing 0 L2C hits; 0 nanoseconds spent performing 0 L2C misses; 1095389 nanoseconds spent executing 1 flushes (flushing a total of 3 entities and 3 collections); 17600 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)
The execution of the same request, but the different duration of the execution time.
source share