关于Hibernate的OpenSessionInView的有关问题

关于Hibernate的OpenSessionInView的问题
Struts2+Spring3+Hibernate3
异常:org.hibernate.HibernateException: createCriteria is not valid without active transaction
--------------
hibernate.xml文件:
<bean id="hibernateProperties"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="properties"><props>
  <prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
  <prop key="hibernate.show_sql">false</prop>
  <prop key="hibernate.max_fetch_depth">1</prop>
  <prop key="hibernate.jdbc.batch_size">3</prop>
  <prop key="hibernate.order_updates">true</prop>
  <prop key="hibernate.max_fetch_depth">1</prop>
  <prop key="hibernate.use_get_generated_keys">true</prop>
  <prop key="hibernate.generate_statistics">false</prop>
  <prop key="hibernate.cache.use_structured_entries">false</prop>
  <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider
  </prop>
  <prop key="hibernate.cache.use_second_level_cache">false</prop>
  <prop key="hibernate.cache.use_query_cache">false</prop>
  <!--
  <prop key="hibernate.current_session_context_class">thread</prop>
  -->
  </property>
</bean>
==========
<bean id="sessionFactory" destroy-method="destroy"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
<ref bean="connectionFactory" />
  </property>
  <property name="hibernateProperties">
       <ref bean="hibernateProperties" />
  </property>
  <property name="mappingDirectoryLocations">
    <list>
<value>classpath: job/model/</value>
    </list>
  </property>
</bean>
==========
<bean id="dialetMapping"
class="com.util.mapping.CaseInsensitiveKeyValueMapping">
<property name="mapping">
  <map>
    <entry key="oracle">
               <value> com.util.hibernate.Oracle9Dialect </value>
    </entry>
           </map>
</property>
</bean>

===========
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="sessionFactory" />
</bean>
===========
<tx:annotation-driven transaction-manager="txManager"/>
---------------------------------
web.xml配置文件
<filter> 
        <filter-name>OpenSessionInView</filter-name> 
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> 
</filter>
<filter-mapping>
  <filter-name>OpenSessionInView</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

--------------------
说明:把SSH框架搭建好后,其实只需要在web.xml文件加一个filter就行。<prop key="hibernate.current_session_context_class">thread</prop>这个TAG不起作用,所以删掉或注释掉。
注意:在项目中使用Spring+Hibernate的时候,会开启OpenSessionInViewFilter来阻止延迟加载的错误,但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMode就已经被默认设置为了MANUAL,如果FlushMode是MANUAL或NEVEL,在操作过程中 hibernate会将事务设置为readonly,所以在增加、删除或修改操作过程中会出现如下错误,只要在那个filter里面加上这段代码就OK了
<init-param>  
  <param-name>flushMode</param-name>  
  <param-value>AUTO</param-value>  
  </init-param>