Second Level Cache

loads_From_Cache

Load an address.

Reopen session.

Load the same address again.

Address is not loaded from database.

loads_From_Cache_Only_After_Session_Is_Closed_Once

Load an address.

Clear session.

Load the same address again.

Address is loaded from database.

loading_Via_Collection_Doesnt_Hit_The_Cache

Load all addresses for a customer.

Reopen session.

Load all addresses for the same customer.

Addresses are loaded from the database.

Note: When children entities are loaded via the parent, hibernate doesn't know the IDs of the children, hence the load happens from the database even when the entities are present in the cache.