Repeating queries for associations marked with @Cache and @Filter in Hibernate

Solution Verified - Updated -

Issue

  • A collection association is marked cacheable and also has a filter

        @OneToMany(...)
        @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
        @Filter(...)
        private List<Employee> employees;
    
  • Attempts to access the association within each new session seem to bypass the cache and trigger a database query

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) (all versions)
  • Hibernate (all versions)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content