title: Spring Boot JPA & H2 Records Not Persisted
body: <p>As a baseline I'm using the Spring Boot demo <a href="https://spring.io/guides/gs/accessing-data-jpa/" rel="nofollow">Accessing Data JPA</a>.</p>
  
  <p>My goal is to be able to view the persisted entities using the h2 console.  I'm able to run the application with Maven, but when I subsequently connect with the h2 console, the database is empty.</p>
  
  <p>If I set <code>spring.jpa.hibernate.ddl_auto=none</code> then the application does not run, so I know that this value is being picked up from <code>src/main/resources</code>, however it I set it to <code>create</code> or <code>update</code>, the database is still empty at the end of the <code>mvn spring-boot:run</code> run.</p>
  
  <p>In the past versions of Spring and Hibernate I have set auto_dll=create, and Hibernate has created the database, if it did not already exists.  Does this no longer work?</p>
  
  <p>This is what the updated example application looks like, minus import declarations:</p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  public class Application {
  
      @Bean
      public DataSource dataSource() {
          HikariConfig config = new HikariConfig();
          config.setDriverClassName("org.h2.Driver");
          config.setJdbcUrl("jdbc:h2:file:~/db1");
          config.setUsername("sa");
          config.setPassword("");
          return new HikariDataSource(config);
      }
  
  public static void main(String[] args) {
  
      ConfigurableApplicationContext context = SpringApplication.run(Application.class);
      CustomerRepository repository = context.getBean(CustomerRepository.class);
  
      // save a couple of customers
      repository.save(new Customer("Jack", "Bauer"));
      repository.save(new Customer("Chloe", "O'Brian"));
      repository.save(new Customer("Kim", "Bauer"));
      repository.save(new Customer("David", "Palmer"));
      repository.save(new Customer("Michelle", "Dessler"));
  
      // fetch all customers
      Iterable&lt;Customer&gt; customers = repository.findAll();
      System.out.println("Customers found with findAll():");
      System.out.println("-------------------------------");
      for (Customer customer : customers) {
          System.out.println(customer);
      }
      System.out.println();
  
      // fetch an individual customer by ID
      Customer customer = repository.findOne(1L);
      System.out.println("Customer found with findOne(1L):");
      System.out.println("--------------------------------");
      System.out.println(customer);
      System.out.println();
  
      // fetch customers by last name
      List&lt;Customer&gt; bauers = repository.findByLastName("Bauer");
      System.out.println("Customer found with findByLastName('Bauer'):");
      System.out.println("--------------------------------------------");
          for (Customer bauer : bauers) {
              System.out.println(bauer);
          }
  
          context.close();
      }
  
  }
  </code></pre>
  
  <p>TIA,
  - Ole</p>