Uploaded image for project: 'Hibernate ORM'
  1. HHH-9573

Add EntityManager test case illustrating usage of query cache

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.2.18, 4.3.9, 5.0.0.Beta1
    • Component/s: testsuite
    • Labels:
      None
    • Last commented by a user?:
      true
    • Sprint:

      Description

      Add an EntityManager test case that illustrates second-level cache eviction expectations when using QueryHints.HINT_CACHEABLE.

      EntityManagerFactory().getCache().evictAll() only evicts entity regions of the second-level cache. The collection and query cache regions are left intact. As a result, query results can still be found in the query cache, but each entity referenced in that query result will result in a "miss" because the entity itself has been evicted from the entity region of the second-level cache. Hibernate will load each "missed" entity from the database (rather than re-executing the original query to obtain all entity data).

      To avoid loading each "missed" entity, the query cache region should also be evicted using:

      EntityManager.unwrap( HibernateEntityManagerImplementor.class )
      .getFactory()
      .getSessionFactory()
      .getCache()
      .evictQueryRegions();

        Attachments

          Activity

            People

            • Assignee:
              gbadner Gail Badner
              Reporter:
              gbadner Gail Badner
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: