2 Replies Latest reply on Jan 11, 2005 12:46 PM by luxmatic

    Multiple .har possible?

    luxmatic

      Using Jboss 3.2.6

      I've successfully deployed a single .har file:

      example1.har
      -Channel.hbm.xml
      -Channel.class
      -META-INF
      --hibernate-service.xml
      
      hibernate-service.xml:
      
      <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=HibernateExample1">
       <attribute name="DatasourceName">java:/jdbc/example1DS</attribute>
       <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
       <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="ShowSqlEnabled">false</attribute>
      </mbean>
      
      



      I'd like to access a different set of tables via a different datasource with a 2nd .har file. Configured much like the 1st, but with a different mbean name, and datasource:

      
      example2.har
      -Distribution.hbm.xml
      -Distribution.class
      -META-INF
      --hibernate-service.xml
      
      hibernate-service.xml:
      
      <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=HibernateExample2">
       <attribute name="DatasourceName">java:/jdbc/example2DS</attribute>
       <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
       <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="ShowSqlEnabled">false</attribute>
      </mbean>
      
      


      I deployed the 2nd .har and, when I run a query, I get a message:
      "net.sf.hibernate.QueryException: unexpected token: as [select v from Distribution as v]
      


      If I remove the 1st .har file and restart the server, the query works.

      If I then hot deploy the 1st .har file, the 2nd .har queries work, but the 1st .har file's fail with the same sort of message.

      What's the trick to configuring/using two hibernate services?




        • 1. Re: Multiple .har possible?
          mveitas

          Try using two differnet sessionFactories.

          • 2. Re: Multiple .har possible?
            luxmatic

             

            "mveitas" wrote:
            Try using two differnet sessionFactories.


            That was the hint I needed. I was under the impression (wrongly) that the sessionFactory was defined and configured elsewhere.

            Changing the 2nd .har's SessionFactoryName to java:/hibernate/SessionFactoryExample2 - and then referring to this name when grabbing the session in the code - allowed it to work.

            Thanks much!