1 Reply Latest reply on Nov 1, 2005 5:12 PM by patrick_ibg

    Insert SQL on deploy

    camross

      I've seen this question previously, but it has not yet been answered. I can't get SQL commands stored in an import.sql file to load data into my database.

      The following configuration appears to function properly:
      - jboss-4.0.3 SP1
      - jboss-EJB-3.0_RC3
      - Sun's JDK 1.5.0_05
      - Linux Fedora Core 3
      - MySQL 14.7

      I have the following very simple POJO Entity:
      @Entity(access = AccessType.FIELD)
      public class Principle implements Serializable
      {
      @Id
      @Length(min=3, max=25)
      private String username;
      public String getUsername() { return username; }
      public void setUsername(String username) { this.username = username; }
      }

      and an import.sql script that looks like this:
      insert into Principle (username) values ('test');

      my persistence.xml file looks like this (angle brackets removed to post correctly):

      <entity-manager>
      pandoDatabase
      org.hibernate.ejb.HibernatePersistence
      <jta-data-source>java:/pandoDatasource</jta-data-source>
      properties
      property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/
      property name="hibernate.hbm2ddl.auto" value="create-drop"/
      /properties
      </entity-manager>

      Everything gets packed into an ejb3 archive and deployed into the container. My log indicates that the insertion from import.sql is occurring, but the resulting tables are empty. Note that I can cut and paste the import command into the mysql command client to load the data.

      Any help is greatly appreciated.

      Cheers,
      Cameron.