Hibernate version:
3.0
I have a question regarding the second level cache.
What is the difference between:
Code:
Criteria crit = hSes.createCriteria(UniExtProcedure.class);
crit.add(
Restrictions.eq("myBKey", "b")
).setCacheable(true);
and
Code:
Criteria crit = hSes.createCriteria(UniExtProcedure.class);
crit.add(
Restrictions.naturalId().set("myBKey", "b")
).setCacheable(true);
(in the second case, the mapping is correct, using natural-id lookup).
When doing a detailed log, the key for the L2 cache looks very similar in both cases and the only way to hit the L2 cache is to repeat the same query twice (for the first and second case)
This is logical for the first case, but for the second one Hibernate has some idea about the meaning of the lookup key.
Is there something similar to the load(class, id) from the L1 cache to help me to the native-id lookup in another way?