title: File based h2 persisted but not loaded in Spring Boot
body: <p>I made a small application based on Spring Boot:</p>
  
  <ul>
  <li>spring-boot-starter-web</li>
  <li>spring-boot-starter-data-jpa</li>
  </ul>
  
  <p>The application has simply one domain class <code>Post.java</code>.
  Accordingly there is a RestController and a DAO.
  The data is supposed to be persisted in a file based hsql db.</p>
  
  <p>When the application is running everything seems fine. Data is stored.
  The h2 file is created and contains insert statements.</p>
  
  <p>However, when I kill the application and start it a second time. No data is loaded. (As if a brand new db file was created, which overwrote the old one).</p>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>spring.datasource.url = jdbc:h2:file:~/testdb
  spring.datasource.username = sa
  spring.datasource.password = sa
  spring.datasource.driverClassName = org.h2.Driver
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;!-- Spring Boot Web --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
  &lt;/dependency&gt;
  
  &lt;!-- Spring Boot Data JPA --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
  &lt;/dependency&gt;
  
  &lt;!-- H2 DB --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.h2database&lt;/groupId&gt;
      &lt;artifactId&gt;h2&lt;/artifactId&gt;
      &lt;version&gt;1.4.179&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>PostDAO.java</strong></p>
  
  <pre><code>public interface PostDAO extends JpaRepository&lt;Post, Integer&gt;{
      public Post findByMessage(String message);
  }
  </code></pre>
  
  <p><strong>Post.java</strong></p>
  
  <pre><code>@Entity
  public class Post {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Long id;
      private String message;
  
      public Post(){
      }
  
      public Post(String message) {
          super();
          this.message = message;
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  }
  </code></pre>