首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring事宜配置总结

2012-08-28 
spring事务配置总结事务代理标准写法 !--DAO层接口实现--bean iduserDAO //property/bean !--

spring事务配置总结
事务代理标准写法


<!--DAO层接口实现  -->
<bean id="userDAO" />
       </property>
</bean>
<!--业务层接口实现,把DAO注入到Service里面 -->
<bean name="userServiceTarget" />
       </property>
</bean>
<!--spring代理业务层的事务管理 -->
<bean id="userServiceProxy"  />
       </property>
       <property name="transactionAttributes">
              <props>
                    <prop key="insert*">PROPAGATION_REQUIRED</prop>
                    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
              </props>
       </property>
       <property name="target">
              <ref bean="userServiceTarget" />
       </property>
</bean>

事务代理简写法


<bean id="baseTxProxy" lazy-init="true"
        />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="insert*">PROPAGATION_REQUIRED</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
        </property>
    </bean>
    <bean id="userDAO" />
        </property>
    </bean>
    <bean id="userServiceProxy" parent="baseTxProxy">
        <property name="target">
            <bean />
                </property>
            </bean>
        </property>
    </bean>

事务自动化代理写法


<!-- 定义事务拦截器bean -->
    <bean id="transactionInterceptor" ref="transactionManager"/>
        <property name="transactionAttributes">
            <props>
                <prop key="insert*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="delete*">PROPAGATION_REQUIRED</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>
    <!--定义BeanNameAutoProxyCreator-->
    <bean />
        </property>
    </bean>
    <bean id="userServiceProxy" />
        </property>
    </bean>

转自:http://www.blogjava.net/beauty9235/archive/2008/08/18/222841.html

热点排行