Repeating database queries when accessing leaf class entities marked @Cacheable / @Cache in Hibernate
Issue
- A class hierarchy includes an abstract entity not marked with
@Cacheableor@Cache -
Each time concrete leaf class entities marked with
@Cacheableor@Cacheare accessed, reload from the database occurs... TRACE [org.hibernate.event.internal.DefaultLoadEventListener] ... Object not resolved in any cache: [support.hibernate.entity.FullTimeEmployee#John Smith] ... DEBUG [org.hibernate.SQL] ... select fulltimeem0_.name as name1_0_0_, fulltimeem0_1_.title as title2_0_0_, fulltimeem0_.planCode as planCode1_1_0_ from FullTimeEmployee fulltimeem0_ inner join Employee fulltimeem0_1_ on fulltimeem0_.name=fulltimeem0_1_.name where fulltimeem0_.name=?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6, 7
- Hibernate 4, 5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
