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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.