title: CrudRepository not reading data from schema.sql
body: <p><strong>Setup:</strong> I have a spring-boot application with a simple @Entity Customer object and CustomerRepository. I want to pre-load the database with test-data described <a href="https://stackoverflow.com/questions/28908939/load-spring-boot-database-with-test-data">here in my other question</a> so I created schema.sql and data.sql files to load the database. </p>
  
  <p><strong>Problem:</strong> The CrudRepository seems to be using a different database than the one created with schema.sql and data.sql. I have not explicitly defined a datasource anywhere because I'm hoping that spring-boot can default everything for me (i.e., did not define spring.datasource in application.properties), and even if I do it doesn't do anything.</p>
  
  <pre><code>@Autowired
  CustomerRepository r;
  r.findAll(); // nothing but it should return the row "John Doe"
  </code></pre>
  
  <p>I don't get any errors it just returns nothing when I invoke findAll() on the repository.</p>
  
  <p><strong>schema.sql</strong></p>
  
  <pre><code>drop table customer if exists;
  
  create table customer (
      id bigint auto_increment,
      firstname varchar(80) null,
      lastname varchar(80) null
  );
  </code></pre>
  
  <p>data.sql</p>
  
  <pre><code>insert into customer (firstname, lastname) values ('John', 'Doe');
  </code></pre>
  
  <p>Customer.java</p>
  
  <pre><code>package sample.jsp;
  
  import java.io.Serializable;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  public class Customer implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private long id;
  
      private String firstName;
      private String lastName;
  
      protected Customer() {}
  
      public Customer(String firstName, String lastName) {
          this.firstName = firstName;
          this.lastName = lastName;
      }
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      @Override
      public String toString() {
          return String.format(
                  "Customer[id=%d, firstName='%s', lastName='%s']",
                  id, firstName, lastName);
      }
  
  }
  </code></pre>
  
  <p>CustomerRepository.java</p>
  
  <pre><code>package sample.jsp;
  
  import java.util.List;
  
  import org.springframework.data.repository.CrudRepository;
  
  public interface CustomerRepository extends CrudRepository&lt;Customer, Long&gt; {
  
      List&lt;Customer&gt; findByLastName(String lastName);
      List&lt;Customer&gt; findAll();
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.1.8.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
      &lt;artifactId&gt;TestApp&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;Spring Boot Web JSP Sample&lt;/name&gt;
      &lt;description&gt;Spring Boot Web JSP Sample&lt;/description&gt;
      &lt;url&gt;http://projects.spring.io/spring-boot/&lt;/url&gt;
      &lt;organization&gt;
          &lt;name&gt;Pivotal Software, Inc.&lt;/name&gt;
          &lt;url&gt;http://www.spring.io&lt;/url&gt;
      &lt;/organization&gt;
      &lt;properties&gt;
          &lt;main.basedir&gt;${basedir}/../..&lt;/main.basedir&gt;
          &lt;m2eclipse.wtp.contextRoot&gt;/&lt;/m2eclipse.wtp.contextRoot&gt;
      &lt;/properties&gt;
      &lt;dependencies&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;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;/dependency&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;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;/dependency&gt;           
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;useSystemClassLoader&gt;false&lt;/useSystemClassLoader&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>