When does hibernate use its first level cache? How to register it?

Is there an easy way with a sleep log level to see when the first cache level is used or not?

If I execute the following hql query: "from Document d left join fetch d.folder, where d.id = 2"; several times, in the same session, will the cache be used?

thank

+5
source share
1 answer

The Hibernate L1 cache stores objects by primary key. This means that if you load the same object using load()or get()(I think this also applies to simple queries like:) from Document d where d.id=2, it will be cached.

, L2. , , L1 ( , ), SQL- .

. :

+2

All Articles