title: Multiple SQL import files in Spring Boot
body: <p>Going by the <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-hibernate" rel="noreferrer">Spring Boot reference manual</a>, there are a couple of ways in which we can import data on startup of an application. Combined with an in-memory database, this is rather handy for testing.</p>
  
  <p>The options are to create a file called <code>import.sql</code>, which will be picked up by Hibernate, or to create a file called <code>data.sql</code>, which will be picked up by Spring JDBC. Both of these work fine for me.</p>
  
  <p>However, I like to break up my projects a bit, so I currently have a core domain model, where there are some handy imports to configure core data such as some users, which is used everywhere. I also have function-specific projects where it is useful to re-use that same import of base data, but also import some additional data which is specific to that function.</p>
  
  <p>This is where things are not working so well.</p>
  
  <p>I found <a href="https://stackoverflow.com/a/4047908/395821">an answer to a previous question</a>, where Pascal Thivent mentioned that the <code>hibernate.hbm2ddl.import_files</code> property could be used to define a list of files, as of Hibernate 3.6.0.Beta1. Given that my project is importing 4.3.1.Final, I thought that perhaps this would be available.</p>
  
  <p>So I tried adding the following to my Spring Boot <code>application.properties</code>:</p>
  
  <pre><code>spring.jpa.hibernate.hbm2ddl.import_files=/another-import.sql
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>hibernate.hbm2ddl.import_files=/another-import.sql
  </code></pre>
  
  <p>Unfortunately, neither of these would cause the import to run.</p>
  
  <p>So I'm wondering whether I just made a mess of the properties above (quite likely). Or is there something else that I need to do?</p>
  
  <p>Note that as a workaround, I spotted that Spring JDBC seems to run <code>data.sql</code> after Hibernate runs <code>import.sql</code>. So as long as I don't need more than two imports, I'm able to use <code>import.sql</code> for the base data and then put project-specific imports in <code>data.sql</code>. I can get by with this, but it's not really a solution.</p>