title: JPA, Hibernate and Spring integration : Table doesn't exist Error
body: <p>I just started learning about JPA, and I have a spring application using hibernate.
  I'm trying to do a test by inserting a simple date into mysql database, but I'm getting this error message :</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'banquedb.clients' doesn't exist
  </code></pre>
  
  <p>This is my test code :</p>
  
  <pre><code>public class Test {
      public static void main(String[] args) {
          ClassPathXmlApplicationContext context = 
                  new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
          IBanqueService service = (IBanqueService) context.getBean("service");
          service.addClient(new Client("Ichigo", "AD1"));
          service.addClient(new Client("Kirito", "AD2"));
      }
  }
  </code></pre>
  
  <p>And these my application files:</p>
  
  <p><strong>persistence.xml:</strong></p>
  
  <pre><code>&lt;persistence-unit name="sample" transaction-type="RESOURCE_LOCAL"&gt;
    &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
    &lt;properties&gt;
      &lt;property name="hibernate.show_sql" value="true"/&gt;
      &lt;property name="hibernate.hbm2ddl.auto" value="create"/&gt;
     &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;bean id="dao" class="org.gestion.banque.dao.BanqueDAOImpl"&gt;&lt;/bean&gt;
      &lt;bean id="service" class="org.gestion.banque.service.BanqueServiceImpl"&gt;
          &lt;property name="dao" ref="dao"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/banquedb"&gt;&lt;/property&gt;
          &lt;property name="username" value="root"&gt;&lt;/property&gt;
          &lt;property name="password" value=""&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"&gt;
          &lt;property name="persistenceXmlLocations"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath*:META-INF/persistence.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="defaultDataSource" ref="dataSource"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="persistenceUnitManager" ref="persistenceUnitManager"&gt;&lt;/property&gt;
          &lt;property name="persistenceUnitName" value="sample"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory"&gt;&lt;/property&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
      &lt;context:annotation-config&gt;&lt;/context:annotation-config&gt;
  </code></pre>
  
  <p><strong>Client.java</strong></p>
  
  <pre><code>@Entity
  @Table(name="CLIENTS")
  public class Client implements Serializable {
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Long codeClient;
      private String nomClient;
      private String adresseClient;
      @OneToMany(mappedBy="client",fetch=FetchType.LAZY)
      private Collection&lt;Compte&gt; comptes;
      public Long getCodeClient() {
          return codeClient;
      }
      public void setCodeClient(Long codeClient) {
          this.codeClient = codeClient;
      }
      public String getNomClient() {
          return nomClient;
      }
      public void setNomClient(String nomClient) {
          this.nomClient = nomClient;
      }
      public String getAdresseClient() {
          return adresseClient;
      }
      public void setAdresseClient(String adresseClient) {
          this.adresseClient = adresseClient;
      }
      public Collection&lt;Compte&gt; getComptes() {
          return comptes;
      }
      public void setComptes(Collection&lt;Compte&gt; comptes) {
          this.comptes = comptes;
      }
      public Client() {
          super();
      }
      public Client(String nomClient, String adresseClient) {
          super();
          this.nomClient = nomClient;
          this.adresseClient = adresseClient;
      }
  
  }
  </code></pre>