I am developing an application using Spring MVC (version 3.1), Hibernate (Version 3.5) and MySQL. In this application, I am creating a database schema each time when the application runs. I want to insert some default data into a few tables using import.sql script file. For this I have created import.sql script in the root and using the following statements in hibernate. cfg. xml file.
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.hbm2ddl.import_files">import.sql</property>
<property name="connection.autocommit">true</property>
But I am not getting success to insert default data into tables.
Please guide me.
Spring must know where to find your file.
If you are using maven, there are several way of doing so.
you can use classpath:/import.sql and put your file in src/test/resources or src/main/resources, depending if you need this for test only or not.