2 Replies Latest reply on Mar 19, 2010 8:50 AM by Sascha Janz

    externalize hibernate.cfg.xml

    Sascha Janz Master

      i use a seamgen generated project.

      in our installations we use oracle and sql server

      unfortunately in hibernate.cfg.xml there is the sql dialect, so we need two versions, one for oracle and one for sql server.

      is there a way to externalize hibernate.cfg.xml?

        • 1. Re: externalize hibernate.cfg.xml
          Stuart Douglas Master

          Are you using plain hibernate or JPA?

          For plain hibernate:

           <persistence:managed-hibernate-session name="entityManager" session-factory="#{hibernateFactory}" scope="conversation" auto-create="true">


          <persistence:managed-persistence-context name="entityManager" entity-manager-factory="#{entityManagerFactory}" scope="conversation" auto-create="true">

          Then create a component:

          class MyClass
            public SessionFactory factory()
               //build session factory from external config and return it.

          • 2. Re: externalize hibernate.cfg.xml
            Sascha Janz Master

            i use plain hibernate

            where must i store the hibernate.cfg.xml?