2 Replies Latest reply on May 2, 2011 3:12 PM by devinderpal

    Jboss 4.2 and Hibernate: How do I autogenerate tables in database

    immitev

      Hello everybody,

       

      I'm currently trying to write an application in Jboss 4.2 using Hibernate. I'm trying to autogenerate my table. The database is generated already.

       

      Here is my code: http://pastebin.com/V6sc1Czv

       

      I am not sure what I've done wrong. I've published it using Eclipse and the Eclipse Servers view using Jboss.

       

      Does anybody have any ideas what I might have done wrong?

       

      Thank you,

      Ilian

        • 1. Jboss 4.2 and Hibernate: How do I autogenerate tables in database
          immitev

          Small adition: The DataSource file declared in the hibernate.cfg.xml is in the Jboss_Home/server/default/deploy. Here is the file:

           

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

          <datasources>

            <local-tx-datasource>

              <jndi-name>SampleDS</jndi-name>

              <connection-url>jdbc:mysql://localhost/astrachallenge</connection-url>

              <driver-class>com.mysql.jdbc.Driver</driver-class>

               <min-pool-size>1</min-pool-size>

                <max-pool-size>20</max-pool-size>

                <user-name>root</user-name>

              <password>kralitsa6817</password>-->

              <metadata>

                 <type-mapping>mySQL</type-mapping>

              </metadata>

            </local-tx-datasource>

          </datasources>

          • 2. Jboss 4.2 and Hibernate: How do I autogenerate tables in database
            devinderpal

            In JBoss 6, you can add persistence.xml with below settings. This file is in META-INF dir of EJB.

            <persistence-unit name="<some name>" transaction-type="JTA">

                                  <jta-data-source>java:DefaultDS</jta-data-source>

                                       <properties>

                                                      <property name="hibernate.hbm2ddl.auto" value="update" />

                 </properties>

            </persistence-unit>

             

            Not sure if this will work with Jboss 4. But I think similar settings will go into hibernate.cfg.xml file to autogenerate tables.