Results 1 to 3 of 3

Thread: populate database with import.sql file and hibernate

  1. #1
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default populate database with import.sql file and hibernate

    I have put an import.sql file — exported from my MySQL DB — in the root of my project and have these settings in Persistence.xml
    Code:
    <property name="hibernate.hbm2ddl.auto" value="create"/>
    . I have also tried the META-INF directory.

    What else do I have to do in order to populate my DB before I run my integration tests as well as on deploy? As it is now nothing seems to happen and my DB is empty. I can import the file by hand, but I need this done automatically.
    Last edited by MiB; Dec 20th, 2011 at 02:37 PM.

  2. #2
    Join Date
    Apr 2011
    Posts
    20

    Default You need hibernate.hbm2ddl.import_files property

    With Hibernate 3.6 you need to set hibernate.hbm2ddl.import_files in order to list the files with SQL DML statements you want to execute during SessionFactory creation.

    Code:
    <property name="hibernate.hbm2ddl.import_files" value="/file1.sql,/file2.sql"/>
    I didn't try it, its in the Hiberante Core documentation in the last table in Optional Configuration Properties
    Óscar Rovira Casanova
    orovira@disid.com
    Disid Technologies S.L.
    Software Engineer
    http://www.disid.com

  3. #3
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    Thank you. I will try this. Hibernate works so effective in Spring Roo as to be almost invisible and I've forgotten to read up on the developments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •