title: Getting Transaction not successfully started exception using Spring Hibernate
body: <p>I have a UserProfile entity which I need to save. after saving the entity in the database, I get the following exception:</p>
  
  <pre><code>Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
  </code></pre>
  
  <p>Also when I see the table the entity is persisted instead of doing a rollback!</p>
  
  <pre><code>@Transactional(isolation=Isolation.REPEATABLE_READ)
  public class HibernateUserProfileDAO implements UserProfileDAO {
      private org.hibernate.SessionFactory sessionFactory;
      public UserProfile getUserProfile(int userId) {
          org.hibernate.classic.Session session = sessionFactory.getCurrentSession();
          session.beginTransaction();
          UserProfile userProfile = new UserProfile();
          userProfile.setUserName("sury1");
          session.save(userProfile);
          session.getTransaction().commit();
          session.close();
          return userProfile;
      }
  }
  </code></pre>
  
  <p>I'm using hibernate transaction manager</p>
  
  <pre><code>&lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and my hibernate config is:</p>
  
  <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="packagesToScan" value="com.springheatmvn.domain"/&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.connection.pool_size"&gt;10&lt;/prop&gt;
              &lt;prop key="hibernate.connection.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;     
  &lt;/bean&gt;
  </code></pre>
  
  <p>Can anyone pl. tell me what's going on here?</p>