0 Replies Latest reply on Oct 25, 2008 10:44 AM by Frederic Nauleau

    SQL Queries generated by {entiy.property} and 2nd lvl cache

    Frederic Nauleau Newbie


        I have set the Cache with JBoss Core TreeCache, everything is working:

      • s:cache is working perfectly

      • Hibernates queries which are marked as cacheable are hitted in the cache...

      But I still have a problem:

      I have a page 'viewEntity.xhtml'; this page is loaded with a parameter 'entityId'. I have a Stateless bean that is called the page is loaded (call from pages.xml), this bean gets the parameter 'entityId' and gets the Entity from the database. Finally the entity is outjected to viewEntity (with the scope PAGE).

      Each time I display the viewEntity page I always get the Hibernate queries... I spends few hours to check my configuration and I finally understood where the problem is:

      In 'viewEntity.xhtml' page, I have some EL expressions which need to load the some entity attributes, for exemple:

      • {entity.att1.name} where att1 is a FK to another entity (@OneToOne or @OneToMany)

      • {entity.att2} in a rendered tag to know if 'att2' is null

      All these EL, need to get some data in database, and hibernate doing his job.. Creates the queries and executes queries to load 'att1' and 'att2'...

      My problem is that these QUERIES are never cached..... Why ? I have some page, where 10 / 15 queries are created each time and the data is not changing often...

      In persistence.xml, I have query-cache activated and second-level activated.

        I spend my last day to search about it, but I didn't find any solution.

      If someone knows about it... I invite him to take a coffee !

      Best Regards,