How should I create H2 using SpringBoot?
<p>I'm starting to play with Spring Boot and as part of that I want to create an in memory DB to work with and bootstrap with the application.</p>

<p>Given the config/code below I get no errors in the startup log and can access the application ok, so it does startup (I get template errors about objects not existing), but I don't get any data back from the DAO when calling findAll() (or if I try to call findById(int) ).</p>

<p>So while it seems things are ok (no error in log, log shows it finds the sql to create schema ad attempts to run the data.sql statements) when I try to access data via the DAO I get no Exception, but no data returned.</p>

<p>Any ideas or observations on the code that might be a problem?</p>

<p>I've added the Spring Data / H2 stuff to my pom:</p>

<pre><code>    &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;
</code></pre>

<p>Spring DAO:</p>

<pre><code>public interface PersonDao extends CrudRepository&lt;Person, Integer&gt; {
}
</code></pre>

<p>DB props in application.properties:</p>

<pre><code>server.contextPath=/
server.port=8080
spring.mvc.view.suffix=.ftl

datasource.mine.jdbcUrl=jdbc:h2:tcp://localhost/mem:clubmanagement
datasource.mine.user=sa
datasource.mine.password=
datasource.mine.poolSize=30

logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=DEBUG

spring.jpa.hibernate.ddl-auto=create
</code></pre>

<p>My service:</p>

<pre><code>@Service
public class MemberServiceImpl implements MemberService {

@Autowired
PersonDao dao;

@Override
public Optional&lt;ClubMember&gt; getClubMember(int id) {
    Person dbPerson = dao.findOne(id);
    if(dbPerson == null) {
        return Optional.empty();
    }
    return Optional.of(fromEntity(dbPerson));
}

@Override
public List&lt;ClubMember&gt; allMembers() {
    Iterable&lt;Person&gt; people = dao.findAll();
    List&lt;ClubMember&gt; members = new ArrayList&lt;&gt;();
    people.forEach(person -&gt; {
        members.add(fromEntity(person));
    });
    return members;
}

private ClubMember fromEntity(Person p) {
    ClubMember member = new ClubMember();
    member.setCurrentGrade(p.getCurrentGrade());
    member.setFirstName(p.getFirstName());
    member.setLastName(p.getLastName());
    member.setAssociationMemberId(p.getAssociationMemberId());
    member.setLastGradingDate(p.getLastGradingDate());
    return member;
}
}
</code></pre>

<p>Schema.sql in resources/ :</p>

<pre><code>create table CLUB
  (id int not null, name varchar(60), association_member_id int);

create table PERSON
(
id int not null, grade_id int, first_name varchar(35), last_name varchar(35),
association_membership varchar(12), last_grading_date date
);

create table GRADE
  (id int not null, name varchar(20));
</code></pre>

<p>In data.sql (again in resources directory):</p>

<pre><code>insert into club (id, name, association_member_id) values (1, 'some club', '123');

insert into person (id, grade_id, first_name, last_name, association_membership, last_grading_date)
values (1, 1, 'name', 'lastname', 'a1234', '2016-03-23');
</code></pre>

<p>Entity class I am trying to retrieve (Trying to use Lombock, also new to me, to generate getters/setters):</p>

<pre><code>@Entity
@Table(name = "person")
public @Data class Person {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;

@JoinColumn(name = "grade_id")
private GRADE currentGrade;

@Column(name = "first_name")
private String firstName;

@Column(name = "last_name")
private String lastName;

@Column(name = "association_membership")
private String associationMemberId;

@Column(name = "last_grading_date")
@Temporal(value = TemporalType.DATE)
private Date lastGradingDate;
}
</code></pre>