filter配置如下:
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sf</param-value>
</init-param>
<init-param>
            <param-name>singleSession</param-name>
            <param-value>false</param-value>
        </init-param> 
</filter>

<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
事物配置如下:
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sf"></property>
</bean> <bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sf" />
</bean> <aop:config proxy-target-class="true"> 
<aop:advisor pointcut="execution(* com.test..service.impl.*(..))"  advice-ref="txAdvice"/> 
</aop:config> <tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="exists"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="get*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
 一下有几种情况:
1.当不加入filter那段内容的时候,程序操作N次后卡住(此处我判断应该是事物没有起作用,打开的连接没有关闭,导致连接数超限),但我不知道为什么事物就不起作用了(当我加入filter那段,程序恢复正常)?
2.当filter段去掉
<init-param>
            <param-name>singleSession</param-name>
            <param-value>false</param-value>
        </init-param> 
程序插入或修改或删除时都报org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' er from transaction definition ,想请教下 这段代码的作用是什么,加入这段代码事物有没有起作用?