title: Spring OpenSessionInViewFilter with @Transactional annotation
body: <p>This is regarding Spring <code>OpenSessionInViewFilter</code> using with  <code>@Transactional</code> annotation at service layer.</p>
  
  <p>i went through so many stack overflow  post on this but still confused about whether i should use <code>OpenSessionInViewFilter</code> or not to avoid <code>LazyInitializationException</code>
  It would be great help if somebody help me find out answer to below queries.</p>
  
  <ul>
  <li>Is it bad practice to use <code>OpenSessionInViewFilter</code> in application
  having complex schema.</li>
  <li>using this filter  can cause <code>N+1</code> problem</li>
  <li>if we are using <code>OpenSessionInViewFilter</code> does it mean <code>@Transactional</code> not required? </li>
  </ul>
  
  <p>Below is my Spring config file</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;context:component-scan base-package="com.test"/&gt;
  &lt;context:annotation-config/&gt;
   &lt;bean id="messageSource"
          class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
          &lt;property name="basename" value="resources/messages" /&gt;
          &lt;property name="defaultEncoding" value="UTF-8" /&gt;
      &lt;/bean&gt;
   &lt;bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="/WEB-INF/jdbc.properties" /&gt;
   &lt;bean id="dataSource"
          class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
          p:password="${jdbc.password}" /&gt;
         &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;     
          &lt;property name="configLocation"&gt;
              &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="configurationClass"&gt;
              &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${jdbc.dialect}&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;!--
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
                   --&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
   &lt;tx:annotation-driven /&gt; 
   &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  
    &lt;/bean&gt;
  </code></pre>