title: Auto creating tables failed in Spring JPA
body: <p>I have an issue with Spring JPA, Hibernate, MySQL.
  I have an Entity (Nom.java) and repository (public interface NomRepository extends JpaRepository). They are created and injected just fine.</p>
  
  <p>The issue is that when I'm trying to save a record via repository's save method spring complaines that "Table '' doesn't exist".
  Indeed I do not see this table in MySQL. U've tried different values of hibernate.hbm2ddl.auto but it did not help.</p>
  
  <p>I use XML-less configuration BTW.</p>
  
  <p>Here's the config file:</p>
  
  <pre><code>package ru.interosite.awp.config;
  
  import java.util.Properties;
  import javax.sql.DataSource;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  import org.springframework.jdbc.datasource.DriverManagerDataSource;
  import org.springframework.orm.jpa.JpaVendorAdapter;
  import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  import org.springframework.orm.jpa.vendor.Database;
  import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  
  @Configuration
  @ComponentScan("ru.interosite.awp")
  @EnableAutoConfiguration
  public class AppConfiguration {
  
      @Bean
      public DataSource dataSource() {
          DriverManagerDataSource dataSource = new DriverManagerDataSource();
          dataSource.setDriverClassName("com.mysql.jdbc.Driver");
          dataSource.setUrl("jdbc:mysql://localhost:3306/awp");
          dataSource.setUsername("root");
          dataSource.setPassword("password");
          return dataSource;
      }
  
      @Bean
      public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
          LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
          lef.setPersistenceUnitName("my_pu");
          lef.setPackagesToScan("ru.interosite.awp.data");
          lef.setDataSource(dataSource);
          lef.setJpaVendorAdapter(jpaVendorAdapter);
          lef.setJpaProperties(getJpaProperties());
          return lef;
      }
  
      @Bean
      public JpaVendorAdapter jpaVendorAdapter() {
          HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
  
          jpaVendorAdapter.setDatabase(Database.MYSQL);
          jpaVendorAdapter.setGenerateDdl(true);
          jpaVendorAdapter.setShowSql(true);
          jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5Dialect");
  
          return jpaVendorAdapter;
      }
  
      private Properties getJpaProperties() {
          return new Properties() {
              {
                  setProperty("hibernate.hbm2ddl.auto", "update");
                  setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
                  setProperty("hibernate.show_sql", "true");
                  setProperty("hibernate.format_sql", "true");
              }
          };
      }
  }
  </code></pre>
  
  <p>Here's how I start the app:</p>
  
  <pre><code>package ru.interosite.awp;
  
  import java.awt.Font;
  import javax.swing.UIManager;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.boot.SpringApplication;
  import org.springframework.context.ApplicationContext;
  import ru.interosite.awp.config.AppConfiguration;
  import ru.interosite.awp.gui.UIUtils;
  
  public class Boot {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(Boot.class);
  
      public static void main( String[] args )
      {
  
          UIUtils.setUIFont(new javax.swing.plaf.FontUIResource(Font.SANS_SERIF, Font.PLAIN, 16));
  
          try {
              String lafClassName = UIManager.getSystemLookAndFeelClassName();
              UIManager.setLookAndFeel(lafClassName);
          } catch (Exception e) {
              LOGGER.debug(e.getMessage());
          }        
  
          ApplicationContext ctx = SpringApplication.run(AppConfiguration.class, args);
          ((Runner)ctx.getBean("runner")).start();
      }    
  }
  </code></pre>
  
  <p>This is my pom.xml:</p>
  
  <pre class="lang-xml prettyprint-override">
  
      &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
      &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; 
               xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;
               xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
          &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
          &lt;groupId&gt;ru.interosite&lt;/groupId&gt;
          &lt;artifactId&gt;AWP&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;packaging&gt;jar&lt;/packaging&gt;
  
          &lt;name&gt;AWP&lt;/name&gt;
          &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
          &lt;properties&gt;
              &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
              &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
              &lt;start-class&gt;ru.interosite.awp.Runner&lt;/start-class&gt;
          &lt;/properties&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;0.5.0.M4&lt;/version&gt;
          &lt;/parent&gt;
  
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-tx&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;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;mysql&lt;/groupId&gt;
                  &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                  &lt;version&gt;5.1.26&lt;/version&gt;
              &lt;/dependency&gt;
  
              &lt;dependency&gt;
                  &lt;groupId&gt;org.mockito&lt;/groupId&gt;
                  &lt;artifactId&gt;mockito-all&lt;/artifactId&gt;
                  &lt;version&gt;1.9.5&lt;/version&gt;
              &lt;/dependency&gt;                                        
          &lt;/dependencies&gt;
  
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt; 
                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; 
                      &lt;version&gt;2.3.2&lt;/version&gt; 
                  &lt;/plugin&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;/plugins&gt;
          &lt;/build&gt;
  
          &lt;repositories&gt;
              &lt;repository&gt;
                  &lt;id&gt;spring-snapshots&lt;/id&gt;
                  &lt;name&gt;Spring Snapshots&lt;/name&gt;
                  &lt;url&gt;http://repo.spring.io/libs-snapshot&lt;/url&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;true&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/repository&gt;
              &lt;repository&gt;
                  &lt;id&gt;spring-milestones&lt;/id&gt;
                  &lt;name&gt;Spring Milestones&lt;/name&gt;
                  &lt;url&gt;http://repo.spring.io/libs-milestone&lt;/url&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;false&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/repository&gt;
              &lt;repository&gt;
                  &lt;id&gt;org.jboss.repository.releases&lt;/id&gt;
                  &lt;name&gt;JBoss Maven Release Repository&lt;/name&gt;
                  &lt;url&gt;https://repository.jboss.org/nexus/content/repositories/releases&lt;/url&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;false&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/repository&gt;
          &lt;/repositories&gt;
  
          &lt;pluginRepositories&gt;
              &lt;pluginRepository&gt;
                  &lt;id&gt;spring-snapshots&lt;/id&gt;
                  &lt;name&gt;Spring Snapshots&lt;/name&gt;
                  &lt;url&gt;http://repo.spring.io/libs-snapshot&lt;/url&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;true&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/pluginRepository&gt;
              &lt;pluginRepository&gt;
                  &lt;id&gt;spring-milestones&lt;/id&gt;
                  &lt;name&gt;Spring Milestones&lt;/name&gt;
                  &lt;url&gt;http://repo.spring.io/libs-milestone&lt;/url&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;false&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/pluginRepository&gt;
          &lt;/pluginRepositories&gt;        
  
      &lt;/project&gt;
  
  </pre>