4 Replies Latest reply on Jul 6, 2006 3:37 PM by Arnie Morein

    JBoss and Hibernate - mapping of classes to connections

    Arnie Morein Novice

      I am using Hibernate 3.x.

      I am working on an application that uses data from three different databases (in dev, also on the same server, but prod could be different servers). Anyway, so far so good but I do not grasp just how Hibernate knows (if it does at all) that entity class X is to be found on connection Y.

      Since the configuration xml file doesn't list the entities related to the connection, are they automatically related to all Hbm connections?

      Is there no way to relate the objects?

        • 1. Re: JBoss and Hibernate - mapping of classes to connections
          Weston M. Price Master

          This is not really a JCA question, but falls more on the Hibernate side.

          However, your hibernate-cfg.xml should appropriate map your entity objects, to your connection configuration. Assuming that you have n databases, you would need n hibernate-cfg.xml files. Each cfg file should have a reference to a datasource for that particular set of entities you want it to be responsible for.

          What DB are you using?



          • 2. Re: JBoss and Hibernate - mapping of classes to connections
            Arnie Morein Novice

            Sorry about the wrong forum; Sybase 12.x. I have several dozen hbm.xml files for each entity class, and one hibernate-service.xml file (below). I found an old document (somewhere that showed (maybe in Hibenate 2.x and pre-JBoss AS 4) the various entities linked to a specific connection but trying that generated an error).

            The Hibernate engine during configuration, seems to read each hbm.xml file N times - one for each SessionFactory defined below. Seems to be a bit of a waste considering some don't belong on certain ones...?

            <?xml version="1.0" encoding="UTF-8"?>


            <!-- datasource settings -->
            java:/applicationSecurity
            org.hibernate.dialect.SybaseDialect
            <!-- bind the hibernate service to jndi -->
            java:/hibernate/SfApplicationSecurity
            org.hibernate.cache.HashtableCacheProvider
            <!-- logging -->
            true


            <!-- datasource settings -->
            java:/working
            org.hibernate.dialect.SybaseDialect
            <!-- bind the hibernate service to jndi -->
            java:/hibernate/SfWorking
            org.hibernate.cache.HashtableCacheProvider
            <!-- logging -->
            true


            <!-- datasource settings -->
            java:/common
            org.hibernate.dialect.SybaseDialect
            <!-- bind the hibernate service to jndi -->
            java:/hibernate/SfCommon
            org.hibernate.cache.HashtableCacheProvider
            <!-- logging -->
            true


            <!-- datasource settings -->
            java:/employeeWarehouse
            org.hibernate.dialect.SybaseDialect
            <!-- bind the hibernate service to jndi -->
            java:/hibernate/SfEmployeeWarehouse
            org.hibernate.cache.HashtableCacheProvider
            <!-- logging -->
            true


            • 3. Re: JBoss and Hibernate - mapping of classes to connections
              Weston M. Price Master

              Again, this is more on the Hibernate side of things. Could you please move your post there?

              • 4. Re: JBoss and Hibernate - mapping of classes to connections
                Arnie Morein Novice

                If by move it there you are referring to the Hibernate.org site, that isn't an option. They have NO documentation on using it from JBoss as a AS service. Is there a particular forum here for this?