一些关于hibernate 与 spring 事务管理的问题

问题相关内容,在下面的链接里
http://cy.lzu.edu.cn/blog/article.php?tid=489
http://spring.jactiongroup.net/viewtopic.php?p=5791
http://www.javaeye.com/t/17339.html

简单来说,就是因为lazy的问题,采用了org.springframework.orm.hibernate3.support.OpenSessionInViewFilter,
但是这东东不太友好哦!

目前我的解决办法如下:
 spring原码不用改,
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter只管在web.xml文件里加载,不用带任何参数,
在业务层继承一个父类来管理事务:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    
<!--Base TransactionProxyed Service Bean-->
    
<bean id="baseTxService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
          abstract
="true">
        
<property name="transactionManager" ref="transactionManager"/>
        
<property name="proxyTargetClass" value="true"/>

        
<property name="transactionAttributes">
            
<props>
                
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="save*">PROPAGATION_REQUIRED</prop>
                
<prop key="update*">PROPAGATION_REQUIRED</prop>
                
<prop key="remove*">PROPAGATION_REQUIRED</prop>
                
<prop key="set*">PROPAGATION_REQUIRED</prop>
                
<prop key="change*">PROPAGATION_REQUIRED</prop>
                
<prop key="delete*">PROPAGATION_REQUIRED</prop>
            
</props>
        
</property>
        
<property name="preInterceptors">
            
<list>
                
<ref bean="methodSecurityInterceptor"/>
            
</list>
        
</property>
    
</bean>
</beans>

    <bean id="infopathManager" parent="baseTxService" autowire="byName">
        
<property name="target">
            
<bean class="com.gdlinkway.ebop.infopath.manager.InfopathManager"/>
        
</property>
    
</bean>

业务层的方法名的前面关键字,自己加上去。
就这样子。
posted @ 2006-10-26 00:45  电视机9号  阅读(970)  评论(0编辑  收藏  举报