2 Replies Latest reply on Sep 6, 2005 7:51 PM by Chris Malan

    Getting MySQL to create tables

    Rafał Sontowski Newbie

      I've had the same problem with MSSQL.
      Try to modify your persistance.xml and put additional .
      It works for me.

      <entity-manager>
       <name>articles</name>
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/articles</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
       <property name="hibernate.case.use_query_cache">true</property>
       <property name="hibernate.show_sql">false</property>
       <property name="hibernate.hbm2ddl.auto">create</property>
       </properties>
       <property name="hibernate.connection.datasource" value="java:/articles"/>
      </entity-manager>
      


        • 1. Re: Getting MySQL to create tables
          Rafa&#322; Sontowski Newbie


          <entity-manager>
           <name>articles</name>
           <provider>org.hibernate.ejb.HibernatePersistence</provider>
           <jta-data-source>java:/articles</jta-data-source>
           <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
           <property name="hibernate.case.use_query_cache">true</property>
           <property name="hibernate.show_sql">false</property>
           <property name="hibernate.hbm2ddl.auto">create</property>
           <property name="hibernate.connection.datasource" value="java:/articles"/>
           </properties>
          
          </entity-manager>
          


          • 2. Re: Getting MySQL to create tables
            Chris Malan Novice

            Thanks Robaks,

            How on earth did you find out about adding that line? An old Hibernate hand?

            Updating to the 3.1.X driver also did it. However, there is now another problem. Tables are created and entries persisted, but on restarting the server the table is empty again. No doubt the SQL code generated to create the tables check for table existence (if exists), drops them if they exist and recreates them.

            This is of course a serious problem. One would be very unhappy in a production environment if the server goes down and all tables are empty on restart. Another argument in favour of a back-up protocol.

            I'll post on this one and see what comes up.

            Thanks again.