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

    Insert SQL on deploy

    Cameron Ross Newbie

      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
      @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):

      property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/
      property name="hibernate.hbm2ddl.auto" value="create-drop"/

      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.