title: OpenSessionInViewInterceptor not working with Hibernate
body: <p>I am using the OpenSessionInViewInterceptor in my code
  Code snippet:</p>
  
  <pre><code>&lt;context:component-scan base-package="com.abc.service" /&gt;
  
  &lt;bean id="handlerMapping"
      class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
      &lt;property name="interceptors"&gt;
          &lt;list&gt;
              &lt;ref bean="openSessionInViewInterceptor" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/abcTest" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="root" /&gt;
  &lt;/bean&gt;
  
  
  &lt;!-- Hibernate 4 SessionFactory Bean definition --&gt;
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan" value="com.abc.entity" /&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="applicationUtil" class="com.abc.util.ApplicationUtil" /&gt;
  
  &lt;bean id="auctionDao" class="com.abc.dao.AuctionDaoImpl"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;bean name="openSessionInViewInterceptor"
      class="org.springframework.orm.hibernate4.support.OpenSessionInViewInterceptor"&gt;
      &lt;property name="sessionFactory"&gt;
          &lt;ref bean="sessionFactory" /&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Other details I am not mentioning here.
  In my DAO I have a method </p>
  
  <pre><code>@SuppressWarnings("unchecked")
  @Transactional(readOnly = false)
  public List&lt;Item&gt; fetchCurrentlyActiveBids() throws RuntimeException {
  
      Session session = sessionFactory.getCurrentSession();
      session.beginTransaction();
      Criteria criteria = session.createCriteria(Item.class);
      criteria.add(Restrictions.eq("isActive", true));
      List&lt;Item&gt; itemList = criteria.list();
      //session.close();
      return itemList;
  }
  </code></pre>
  
  <p>I am able to hit my dao and get data for few times. Then again when I am repeatedly calling this method using rest client (thorugh rest end point) I get the following error:</p>
  
  <p>{
    "statusCode": 500,
    "statusDescription": "Internal Server Error",
    "errorMessage": "nested transactions not supported"
  }`</p>
  
  <p>Not able to understand why nested transaction not supported is showing? If I use OpenSessionInViewInterceptor it should automatically close the session after use. Kindly suggest a solution</p>
  
  <p><strong>Edited Configuration Section</strong></p>