title: Spring Hibernate JPA HSQL Table not found in statement
body: <p>I'm training Spring persistence with LocalContainerEntityManagerFactoryBean and getting error:</p>
  
  <pre><code> Caused by: java.sql.SQLException: Table not found in statement [insert into PERSON      (ID, email, name) values (null, ?, ?)]
  </code></pre>
  
  <p>Don't really know what I did wrong</p>
  
  <p>My Main class (for test only)</p>
  
  <pre><code>    package com.me.test;
  
      import com.me.model.Person;
      import com.me.service.PersonService;
      import java.util.List;
      import java.util.logging.Logger;
      import org.springframework.context.ApplicationContext;
      import org.springframework.context.support.ClassPathXmlApplicationContext;
  
      public class Main {
  
      /**
       *
       */
      public static final Logger log = Logger.getLogger(Main.class.getName());
      public static void main(String[] args) {
          log.info("************** BEGINNING PROGRAM **************");
  
          ApplicationContext context = new ClassPathXmlApplicationContext("WEB-INF/spring-config.xml");
          PersonService personService = (PersonService) context.getBean("personService");
  
          Person person = new Person();
          person.setName("name");
          person.setEmail("name@name.com");
          personService.addPerson(person);
          log.info("Person : " + person + " added successfully");
  
          List&lt;Person&gt; persons = personService.fetchAllPersons();
          log.info("The list of all persons = " + persons);
  
          log.info("************** ENDING PROGRAM *****************");
      }
  }
  </code></pre>
  
  <p>My application context:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
             http://www.springframework.org/schema/aop
             http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
             http://www.springframework.org/schema/context
             http://www.springframework.org/schema/context/spring-context-3.0.xsd
             http://www.springframework.org/schema/tx  
             http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;
  
      &lt;context:component-scan base-package="com.me" /&gt;
  
      &lt;bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" /&gt;
          &lt;property name="persistenceUnitName" value="personPersistenceUnit" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="jpaVendorAdapter" ref="jpaVendorAdapter" /&gt;
          &lt;property name="jpaDialect" ref="jpaDialect" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jpaVendorAdapter"
          class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
          &lt;property name="database" value="HSQL" /&gt;
          &lt;property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="jpaDialect" ref="jpaDialect" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver" /&gt;
          &lt;property name="url" value="jdbc:hsqldb:file:/home/me/Pulpit/hsql1/db3; shutdown=true" /&gt;
          &lt;property name="username" value="sa" /&gt;
          &lt;property name="password" value="" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dbUtil" class="com.me.service.DbUtil"&gt;
  &lt;!--        init-method="initialize"&gt;--&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt; 
  
  persistence.xml:
  
      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
      version="1.0"&gt;
          &lt;persistence-unit name="personPersistenceUnit" transaction-type="RESOURCE_LOCAL" &gt;
              &lt;class&gt;com.me.model.Person&lt;/class&gt;
          &lt;/persistence-unit&gt;
      &lt;/persistence&gt; 
  </code></pre>
  
  <p>PersonService class</p>
  
  <pre><code>package com.me.service;
  
  import com.me.dao.PersonDao;
  import com.me.model.Person;
  import java.util.List;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  @Component
  public class PersonService {
  
      private PersonDao personDao;
  
      public PersonDao getPersonDao() {
          return personDao;
      }
      @Autowired
      public void setPersonDao(PersonDao personDao) {
          this.personDao = personDao;
      }
  
      public void addPerson(Person person) {
          getPersonDao().insert(person);
      }
  
      public List&lt;Person&gt; fetchAllPersons() {
          return getPersonDao().selectAll();
      }
  }
  </code></pre>
  
  <p>personDAO class</p>
  
  <pre><code>package com.me.dao;
  
  import com.me.model.Person;
  import java.util.List;
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.PersistenceContext;
  import javax.persistence.Query;
  import org.springframework.stereotype.Repository;
  import org.springframework.transaction.annotation.Propagation;
  import org.springframework.transaction.annotation.Transactional;
  
  @Repository("personDao")
  @Transactional(propagation = Propagation.REQUIRED)
  public class PersonDao {
  
      private static final String SELECT_QUERY = "select p from Person p";
  
      @PersistenceContext
      private EntityManager entityManager;
  
      public EntityManager getEntityManager() {
          return entityManager;
      }
  
      public void setEntityManager(EntityManager entityManager) {
          this.entityManager = entityManager;
      }
  
      public void insert(Person person) {
          entityManager.persist(person);
      }
  
      public List&lt;Person&gt; selectAll() {
          Query query = entityManager.createQuery(SELECT_QUERY);
          List&lt;Person&gt; persons = (List&lt;Person&gt;) query.getResultList();
          return persons;
      }
  
  }
  </code></pre>
  
  <p>What's wrong here guys?</p>
  
  <p>edit:
  adding person class:</p>
  
  <pre><code>package com.me.model;
  
  import java.io.Serializable;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "PERSON")
  public class Person implements Serializable{
  
      private Integer id;
      private String name;
      private String email;
  
      @Id
      @GeneratedValue
      @Column(name = "ID")
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      @Override
      public String toString() {
          return "Person [id=" + id + ", name=" + name + ", email=" + email + "]";
      }
  
  }
  </code></pre>
  
  <p>and persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
      version="1.0"&gt;
      &lt;persistence-unit name="personPersistenceUnit" transaction-type="RESOURCE_LOCAL" &gt;
      &lt;class&gt;com.me.model.Person&lt;/class&gt;
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt; 
  </code></pre>