5 Replies Latest reply on May 5, 2009 6:01 AM by manik

    Using JBC 3 with Hibernate (3.3)

    nlif

      Hi all,

      I am unable to find any documentation for using JBC 3 with Hibernate (3.3). In the Wiki it says this is possible and even recommended - see:

      http://www.jboss.org/community/docs/DOC-10265.

      However, the only thing I could find is a PDF for using JBC 2 with Hibernate - see:

      http://galder.zamarreno.com/wp-content/uploads/2008/09/hibernate-jbosscache-guide.pdf.

      Moreover, in the Hibernate reference there is a table of supported cache providers, and JBC 3 is not listed (JBC 2 is, though) - see:

      http://www.hibernate.org/hib_docs/v3/reference/en/html/performance-cache.html

      Is this possible? Is there documentation?

      Thanks,
      Naaman

        • 1. Re: Using JBC 3 with Hibernate (3.3)

          jbc2 cache provider with hibernate 3.3.1 works with jbosscache 3.0.1.

          just specify a hibernate.cache.region.factory_class instead of hibernate.cache.provider_class.

          Also.. treecache.xml has a new syntax. See the provided examples.

          <!--<property name="hibernate.cache.provider_class">org.jboss.hibernate.jbc.cacheprovider.TreeCacheProvider-->
          <property name="hibernate.cache.region.factory_class"> org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory</property>
          


          • 2. Re: Using JBC 3 with Hibernate (3.3)
            nlif

            Thank you.

            According to the Hibernate reference (see: http://www.hibernate.org/hib_docs/v3/reference/en/html/performance-cache.html#performance-cache-compat-matrix), JBC cannot be used for "nonstrict-read-write" or "read-write" modes. It does support "transactional", but if I am not mistaken, this requires JTA support.

            Is this correct?

            Is there support for caching read-write entities, without JTA, for example - using Spring TX support for a single datasource, which uses plain JDBC transactions?

            Thanks again.
            Naaman

            • 3. Re: Using JBC 3 with Hibernate (3.3)
              brian.stansberry

              nlif: Sorry, no, JTA is required.

              soee: FYI, full documentation of the updated Hibernate/JBC integration can be found at https://www.jboss.org/community/servlet/JiveServlet/download/10386-69-6042/hibernate-jbosscache-guide-3.pdf .

              (In case that URL proves fragile, the PDF is an attachment to https://www.jboss.org/community/docs/DOC-10386 .)

              The docs refer to JBC 2, but as you've found JBC 3 works fine. JBoss AS 5 uses the Hibernate 3.3.1/JBC 3.0.1 combination for second level caching. You can also use JBC 3's MVCC locking, which isn't covered in the docs, although from your http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195363#4195363 thread it looks like you've found a bug that affects this.

              • 4. Re: Using JBC 3 with Hibernate (3.3)

                Hi guys,

                I'm also testing Hibernate 3.3.1 and JBoss Cache 3.0.2 from a standalone application, but it seems my app can't get the TransactionManager reference from JNDI.

                This is the hibernate config file I'm using as stated in hibernate-jbosscache doc:

                <hibernate-configuration>
                 <session-factory>
                 <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
                 <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
                
                 <property name="hbm2ddl.auto">update</property>
                
                 <property name="hibernate.cache.region.factory_class">org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory</property>
                 <property name="cache.use_second_level_cache">true</property>
                 <property name="cache.use_query_cache">true</property>
                
                 </session-factory>
                </hibernate-configuration>


                and this are the java options in my app:
                -Djbosscache.config.validate=false -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=jnp://localhost:1097 -Djava.naming.factoy.url.pkgs=org.jnp.interfaces


                The exception
                Caused by: javax.naming.NameNotFoundException: TransactionManager not bound

                These are my questions (take into account I'm not familiar with JTA)
                1.- I'm starting JBoss AS 5.0.0 to have a java:/TransactionManager bound (it is not that my application needs the AS). JBoss AS NS is configured in port 1097 (instead of default 1099). Is there the need to start the AS though ?
                2.- JBossTransactionManagerLookup looks for java:/TransactionManager (according to the source code) but it cannot find it. What is the part I'm missing ??

                Thanks a lot !!
                Ignacio.

                • 5. Re: Using JBC 3 with Hibernate (3.3)
                  manik

                  Does it work if you use the default JNDI port of 1099?