2 Replies Latest reply on Jan 10, 2013 4:13 AM by Viet Tran

    Migrate HAR hibernate archive to AS7

    Red Militante Newbie

      I'm migrating an application packaged as a HAR hibernate archive from JBoss AS5 to AS7.  I have a number of questions, and I know I have a number of hurdles I have to face in order to migrate my application successfully.  I don't mind researching things on my own - but at this point I'm not quite sure what is possible, or the direction I should take and would appreciate any pointers or comments. 

       

       

      I know that JBoss AS7 does not support HAR hibernate archives - so I have to make some sort of changes in order to get this to work.  My app requires hibernate3, which I include as a dependency.  My HAR is structured like

       

       

      HAR

      |

      |-com

      |  |-business classes

      |     |-*class files and *hbm.xml files

      |

      |-META-INF

         |-hibernate.xml

       

       

      My hibernate.xml file looks like

       

       

      <hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">

       

       

         <session-factory name="java:/hibernate/SessionFactory" bean="jboss.har:service=Hibernate">

            <property name="datasourceName">java:/MySqlDS</property>

            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

           

           <!-- <property name="sessionFactoryInterceptor">org.jboss.test.hibernate.SimpleInterceptor</property> -->

           <!-- <property name="hbm2ddlAuto">create</property> -->

            <depends>jboss:service=Naming</depends>

            <depends>jboss:service=TransactionManager</depends>

         </session-factory>

       

       

      </hibernate-configuration>

       

       

      I'm attaching a business class included in my HAR, along with its associated *hbm.xml file.  We are using *hbm.xml files in our HAR to define entities, and not the newer style of hibernate annotations.  A couple of questions I have are:

       

       

      -is there a way I can just package my HAR as a JAR and use it inside of AS7 without having to go through the trouble of rewrite my business classes to use annotations to define entities instead of using *hbm.xml files? 

      -if not is there a guide somewhere about converting your code to use hibernate annotations and persistence.xml?  I don't mind doing research but right now I'm not sure what I should be researching.

        • 1. Re: Migrate HAR hibernate archive to AS7
          jaikiran pai Master

          I think you could just package that app as a simple .jar file with the entity classes and the hbm files and a persistence.xml file:

           

          yourapp.jar
          |
          |--- <com/....../ classes>  and <hbm files>
          |
          |--- META-INF
          |         |
          |         |--- persistence.xml
          

           

          The persistence.xml would be something like:

           

          <?xml version="1.0" encoding="UTF-8"?>
          <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
            <persistence-unit name="mypu">
              <description>JPA application</description>
              <jta-data-source>java:/MySqlDS</jta-data-source>
              <properties>
                  <property name="hibernate.hbm2ddl.auto" value="create"/>
                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/myapp/EntityManagerFactory"/>
                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
              </properties>
          
            </persistence-unit>
          </persistence>
          
          • 2. Re: Migrate HAR hibernate archive to AS7
            Viet Tran Newbie

            Hi Red,

            Did you try the way Jaikiran suggestion? Did it work in your case?

            Regards,