title: Hibernate not creating table when using Spring DAO
body: <p>I'm trying to use Spring DAO with Hibernate for a web application.  When I try to persist information in the DAO using </p>
  
  <pre><code>getHibernateTemplate().save("bar", bar);
  </code></pre>
  
  <p>I get the following in Tomcat:</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: 
  [com.enw.foo.domain.Bar]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.enw.foo.domain.Bar]
  </code></pre>
  
  <p>The log files report:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet foo threw exception
  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'foo.bar' doesn't exist
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39
  </code></pre>
  
  <p>Which is no surprise, I expect that the table doesn't exist.  The database does exist, and I'm counting on Hibernate to generate and alter the tables as necessary.  </p>
  
  <p>The hibernate-mapping file contains:</p>
  
  <pre><code>&lt;class name="Bar" table="BAR"&gt;
    &lt;id name="id" column="BAR_ID"&gt;
    &lt;generator class="native"/&gt;
      &lt;/id&gt;
    &lt;property name="title" column="TITLE"/&gt;
    &lt;property name="date" type="timestamp" column="POST_DATE"/&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>And the spring configuration occurs mainly in <code>foo-data.xml</code> which contains:</p>
  
  <pre><code>&lt;bean id="barDao" class="com.enw.foo.data.impl.HibernatePostDao"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;Domain.hbm.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
              &lt;prop key="show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hbm2ddl.auto"&gt;update&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
             &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/foo"/&gt;
      &lt;property name="username" value="root"/&gt;
      &lt;property name="password" value=""/&gt;
      &lt;property name="initialSize" value="5"/&gt;
      &lt;property name="maxActive" value="10"/&gt;
  &lt;/bean&gt;
  </code></pre>