0 Replies Latest reply on Sep 26, 2008 8:17 AM by Katrin Wippermann

    How to dynamically configure different databases and dialect

    Katrin Wippermann Newbie

      Hi,

      I'm using JBoss 4.0.5 and hibernate 3.1 and integrate Hibernate with the Hibernate MBean and deployed it with a har file. So far everything works fine, but I have to support different timebases with different Dialects, all using the same database scheme. I've searched the forum but I haven't found an example how to configure the Hibernate MBean at runtime. Here is my code:

      the hibernate-service.xml:

      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
       <attribute name="DatasourceName">java:/db1</attribute>
       <attribute name="Dialect">org.hibernate.dialect.SQLServerDialect</attribute>
       <attribute name="SessionFactoryName">hibernate/SessionFactory</attribute>
       <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
       </mbean>
      </server>
      


      Getting the session factory:

       InitialContext context = new InitialContext();
       sessionFactory = (SessionFactory) context
       .lookup("hibernate/SessionFactory");
      


      Can anyone provide an example how to configure the MBean before creating the session factory?

      Thanks

      Katrin