title: EntityManager persist() not saving anything to database
body: <p>My entityManager persist() gets id from sequence and puts it to my Image object but the Image object itself is not showing up in the database. EntityManager.flush() gives an error so I can't commit this way. Here is my code. </p>
  
  <pre><code>@Repository
  public class ImageDaoImpl extends BaseDao implements ImageDao {
  
  @PersistenceContext
  protected EntityManager entityManager;
  
  @Override
  @Transactional
  public void create(Image image) {       
      JpaTemplate jpaTemplate = getJpaTemplate(entityManager);
      jpaTemplate.persist(image);
  }
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>@Repository
  public class BaseDao {
  
  private JpaTemplate jpaTemplate;
  
  
  public JpaTemplate getJpaTemplate(EntityManager entityManager){
      if(jpaTemplate == null)
          jpaTemplate = new JpaTemplate(entityManager);
      return jpaTemplate;
  }
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>&lt;bean id="entityManagerFactory"
         class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
         p:dataSource-ref="dataSource"&gt;
         &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;property name="showSql" value="true" /&gt;
                  &lt;property name="generateDdl" value="true" /&gt;
                  &lt;property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
          &lt;property name="persistenceUnitName" value="sample"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
  
  
      &lt;!-- DataSource Setup --&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/imageCapture" /&gt;
          &lt;property name="username" value="myusername" /&gt;
          &lt;property name="password" value="mypassword" /&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;
  </code></pre>