From what I understand, the L2 cache is useful when finding an entity by using its primary key.
But is there any point using it for queries that are not based on the primary key? E.g.:
SELECT p FROM Person p WHERE p.age > 18
If the query cache is NOT turned on, will the L2 cache be of any use at all?
No, it won't be of any use in that case. The L2 cache is used when getting an entity by its ID, or when navigating through OneToOne and ManyToOne associations (which also causes an entity to be loaded by its ID, unless the referenced column is not the PK).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With