1 Reply Latest reply on Mar 2, 2006 3:58 AM by julesverne

    hibernate and jboss transactionmanager

    julesverne

      Hi
      How do i configure hibernate-sevice.xml which is deployed as a har to use Jboss4.0.2 AS servers transaction manger. so that I can use it with my session beans...
      Here is the current configuration of my hibernate-service.xml

      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
       <attribute name="DatasourceName">java:/DefaultDS</attribute>
       <attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
       <attribute name="SessionFactoryName">java:/HibernateSessionFactory</attribute>
       <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="Hbm2ddlAuto">update</attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
      </server>
      


      Thnx for the help
      Jubs

        • 1. Re: hibernate and jboss transactionmanager
          julesverne

          I picked this from the net...

          However, in the context of a larger J2EE application, you'll likely want your Hibernate objects to take part in an existing JTA transaction. This would be the normal case if you wanted to access Hibernate objects in a session bean, for example.

          JBoss provides the org.jboss.hibernate.session.HibernateContext class as the integration piece that does this. The getSession method returns a Hibernate session that is linked to the current JTA transaction. Naturally this requires that a JTA transaction exist prior to the call. The following code illustrates the use of getSession.

          Session hsession = HibernateContext.getSession("java:/hibernate/ExampleEmptorSessionFactory");
          

          When you get the Hibernate session in this manner, you don't need close the Hibernate session or manage a hibernate transaction. You can be sure that all access to the Hibernate session from the current transaction will see the same state, and you can know that your Hibernate access will be committed to the database or rolled back along with the larger JTA transaction.


          is this the only way....
          thnx