2 Replies Latest reply on Jan 29, 2007 4:59 PM by guy_davis

    Accessing multiple databases

    guy_davis

      Hi all, we're looking to use Seam as the web interface to our existing application. The app has one master database and multiple project databases. Any tips or pointers to how I would configure Seam/Hibernate to connect to the various databases. In particular, if the EntityManager is injected to the beans does that imply only a single database is available?

      Thanks much,
      Guy

        • 1. Re: Accessing multiple databases
          gavin.king

          You can have as many EntityManagerFactory instances as you like, and as many EntityManager instances as you like per transaction. Just give each instance a different name.

          • 2. Re: Accessing multiple databases
            guy_davis

            Good to know. Is it possible to specify these datasources programatically rather than in an XML file. For example in the booking example, there is the jboss-seam-booking.jar!/booking-ds.xml file which contains the details on a single datasource. Should I add multiple data source declarations in this file?

            The reason I ask is that our server application is installed at the client site. Currently we maintain a list of BasicDataSource instances that the server uses internally without requiring the user to touch config files. Ideally, I'd like to set these BasicDataSource objects to the embedded Tomcat context which is running the Seam/EJB3 app.

            Any help would be greatly appreciated.

            Guy