title: Spring+JPA+Hibernate+Postgres configuration
body: <p>I have configuration that works with MySQL, but I would like to switch to Postgres now. I would like to keep it without hibernate-specific classes and configuration files such as SessionFactory and hibernate.cfg.xml. And I would like to keep my persistence.xml minimal.
  With the configuration below when the application starts on Tomcat I don't have the tables created automatically. Database fitnessTracker exists, Postgres server is running.
  How can I test my configuration? Any advice on more verbose debug info at this stage is very welcome.</p>
  
  <p>My configs:</p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:/jpaContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;    
  
  &lt;servlet&gt;
  &lt;servlet-name&gt;fitTrackerServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
  &lt;init-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/config/servlet-config.xml&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;/servlet&gt;....&lt;/web-app&gt;
  </code></pre>
  
  <p>jpaContext.xml (Postgres)</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"&gt;
  
  &lt;context:annotation-config /&gt;
  
  &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;
  
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="punit"/&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="packagesToScan" value="com.pluralsight.model"/&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="true"/&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  
      &lt;property name="jpaPropertyMap"&gt;
          &lt;map&gt;
              &lt;entry key="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/&gt;
              &lt;entry key="hibernate.hbm2ddl.auto" value="create"/&gt;
              &lt;entry key="hibernate.format_sql" value="true"/&gt;
          &lt;/map&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;/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.postgresql.Driver"/&gt;
      &lt;property name="url" value="jdbc:postgresql://localhost:5432/fitnessTracker"/&gt;
      &lt;property name="username" value="postgres"/&gt;
      &lt;property name="password" value="admin"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>META-INF/persistence.xml</p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0"&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>My Entity class</p>
  
  <pre><code>package com.pluralsight.model;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  
  @Entity
  public class Activity {
  
  @Id
  @GeneratedValue
  private Long id;
  
  private String desc;
  
  ...getters and setters
  
  }
  </code></pre>