6 Replies Latest reply on Dec 6, 2012 9:36 AM by jimmy.wahlberg

    Using Infinispan with JBoss EAP 5.1

    helpermethod

      In our current project, we would like to use Infinispan to cache repeatedly called queries.

       

      In order to do so, we set up JPA/Hibernate according to this tutorial:

       

      https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider

       

      Following are some excerpts of the configuration done:

       

      (orm.xml)

       

      <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"

      version="1.0">

       

         <named-query name="retrievePolicySet">

           <query>from PSTRepresentationType p where p.realm=? AND p.policySetType.policySetId=?</query>

           <hint name="org.hibernate.cacheable" value="true" />

         </named-query>

       

         <named-query name="retrievePolicySetList">

           <query>from PSTRepresentationType p where p.realm=?</query>

           <hint name="org.hibernate.cacheable" value="true" />

         </named-query>

      </entity-mappings>

       

       

      (persistence.xml)

       

           <properties><property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />{code}

         <property name="hibernate.show_sql" value="true" />

         <property name="hibernate.format_sql" value="true" />

       

         <property name="hibernate.cache.use_second_level_cache" value="true" />

         <!-- Enables the query cache. Individual queries still have to be set cachable. -->

         <property name="hibernate.cache.use_query_cache" value="true" />

         <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />

       

         <property name="hibernate.cache.infinispan.statistics" value="true" />

      </properties>

       

       

      According to the tutorial this should work but it doesn't. The logs show that Infinispan is used as a second level cache but queries are still not cached (actually, it seems that the cache doesn't get accessed at all).

       

      We also followed this tutorial

       

      https://docs.jboss.org/author/display/ISPN/Infinispan+as+Hibernate+2nd-Level+Cache+in+JBoss+AS+5.x

       

      but also without success.

       

      Thanks in advance,

       

      Oliver

        • 1. Re: Using Infinispan with JBoss EAP 5.1
          sannegrinovero

          Hi,

          the configuration looks good, but unless you enabled caching on the PSTRepresentationType you will still hit the database as the specific entity is not cacheable.

           

          What is your exact definition of "it doesn't work" ?

          What do the statistics expose? Can you post a test or example?

          1 of 1 people found this helpful
          • 2. Re: Using Infinispan with JBoss EAP 5.1
            helpermethod

            How do I enable caching on the PSTRepresentationType? Do I need to annotate the Entity with an @Cache annotation? In our application, we have a WebService that exposes method which return PSTRepresentationType or a List of PSTRepresentationType. Isn't it possible to just annotate the methods, e.g.

             

                @Cache(...)

                public List<PolicySetType> retrievePolicySetList(@WebParam(name = "realm") String realm);

                @Cache(...)

                public PolicySetType retrievePolicySet(@WebParam(name = "realm")String realm, @WebParam(name = "policySetId")String policySetId);

             

            P.S.: Another question, maybe slightly off-topic. Is it actually possible to use JBoss EAP 5.1 with the newest Infinispan version?

             

            Greetings, Oliver

            • 3. Re: Using Infinispan with JBoss EAP 5.1
              galder.zamarreno

              As Sanne suggested, I'd try annotation the entity itself too with @Cacheable and @Cache - http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e2298

              1 of 1 people found this helpful
              • 4. Re: Using Infinispan with JBoss EAP 5.1
                galder.zamarreno

                Btw, if you're using EAP, you should be asking these questions to the JBoss support team which are more than capable of answering these questions and more within an agreed response time

                 

                And Infinispan cannot be plugged into EAP 5.1.

                • 5. Re: Using Infinispan with JBoss EAP 5.1

                  When you say "Infinispan cannot be plugged into EAP 5.1", are you referring to using it with JPA/Hibernate or in general? And does this statement apply to ISPN 5.2.x?

                   

                  The reason I ask is that I'm trying to use ISPN 5.2.0 on SOA-P 5.3 (which is EAP 5.1) and I'm having problems with the version of JBoss Logging that is in EAP (2.1.2) and that which ISPN needs (3.1.0). I've tried using jboss-classloading.xml to isolate the .esb I'm trying to deploy (which includes the ISPN dependencies in the lib dir) but that is taking me down a rabbit hole of class not found and classloader conflict errors, not to mention what seems to be a JBoss LogManager bug where it doesn't pick up the java.util.logging.manager property when I've clearly set it.

                   

                  Is there a document anywhere that tells how to deploy ISPN 5.2.x onto SOA-P 5.x (EAP 5.1)?

                   

                  Thanks.

                  • 6. Re: Using Infinispan with JBoss EAP 5.1
                    jimmy.wahlberg

                    Galder Zamarreño wrote:

                     

                    Btw, if you're using EAP, you should be asking these questions to the JBoss support team which are more than capable of answering these questions and more within an agreed response time

                     

                    And Infinispan cannot be plugged into EAP 5.1.

                     

                    Yes it can I updated the information on your wiki on how to do this.

                     

                    Cheers