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.
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