<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    MDA/MDD/TDD/DDD/DDDDDDD
    posts - 536, comments - 111, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    aop配置事務

    Posted on 2009-12-24 22:04 leekiang 閱讀(300) 評論(0)  編輯  收藏 所屬分類: spring
    事務直接配到DAO上
    <bean id="transactionManager"
    ?? ??? ?class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    ?? ??? ?<property name="dataSource" ref="dataSource" />
    ?? ?</bean>

    ?? ?<bean id="baseTxProxy"
    ?? ??? ?class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
    ?? ??? ?lazy-init="true" abstract="true">
    ?? ??? ?<property name="transactionManager">
    ?? ??? ??? ?<ref bean="transactionManager" />
    ?? ??? ?</property>
    ?? ??? ?<property name="transactionAttributes">
    ?? ??? ??? ?<props>
    ?? ??? ??? ??? ?<prop key="update*">PROPAGATION_REQUIRED</prop>
    ?? ??? ??? ?</props>
    ?? ??? ?</property>
    ?? ?</bean>

    ?? ?<bean id="studentDaoProxy" parent="baseTxProxy">
    ?? ??? ?<property name="target">
    ?? ??? ??? ?<ref bean="studentDao" />
    ?? ??? ?</property>
    ?? ?</bean>

    ?? ?<bean id="studentDao" class="com.dao.StudentDaoImpl">
    ?? ??? ?<property name="dataSource" ref="dataSource" />
    ?? ?</bean>
    ?? ?
    ?? ?StudentDao st = (StudentDao) context.getBean("studentDaoProxy");
    ?? ?
    ?? ?兩個bean也可以合并為
    ?? ?<bean id="studentDao" parent="baseTxProxy">
    ?? ??? ?<property name="target">
    ?? ??? ??? ?<bean class="com.dao.StudentDaoImpl">
    ?? ??? ??? ??? ?<property name="dataSource" ref="dataSource" />
    ?? ??? ??? ??? ?<property name="kpiDao" ref="kpiDao" />
    ?? ??? ??? ?</bean>
    ?? ??? ?</property>
    ?? ?</bean>
    ?? ?StudentDao st = (StudentDao) context.getBean("studentDao");
    ?? ?上述這種方式必須使用接口,為什么。
    ?? ?
    ?? ?
    ?? ?第二種同樣必須用接口。配置起來比第一種麻煩
    ?? ??? ?<bean id="transactionManager"
    ?? ??? ?class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    ?? ??? ?<property name="dataSource" ref="dataSource" />
    ?? ?</bean>

    ?? ?<bean id="transactionInterceptor"
    ?? ??? ?class="org.springframework.transaction.interceptor.TransactionInterceptor">
    ?? ??? ?<property name="transactionManager" ref="transactionManager" />
    ?? ??? ?<property name="transactionAttributes">
    ?? ??? ??? ?<props>
    ?? ??? ??? ??? ?<prop key="update*">PROPAGATION_REQUIRED</prop>
    ?? ??? ??? ?</props>
    ?? ??? ?</property>
    ?? ?</bean>
    ?? ?<bean id="studentDaoProxy"
    ?? ??? ?class="org.springframework.aop.framework.ProxyFactoryBean">
    ?? ??? ?<property name="target" ref="studentDao" />
    ?? ??? ?<property name="interceptorNames">
    ?? ??? ??? ?<list>
    ?? ??? ??? ??? ?<value>transactionInterceptor</value>
    ?? ??? ??? ?</list>
    ?? ??? ?</property>
    ?? ?</bean>
    ?? ?
    ?? ?<bean id="studentDao" class="com.dao.StudentDaoImpl">
    ?? ??? ?<property name="dataSource" ref="dataSource" />
    ?? ?</bean>
    ?? ?ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
    ?? ?StudentDao st = (StudentDao) context.getBean("studentDaoProxy");
    ?? ?
    ?? ?如果使用的都是接口,那么就不需要用cglib-nodep-2.1_3.jar
    ?? ?如果service調dao沒有用到接口,那么必須用cglib-nodep-2.1_3.jar


    事務策略: 了解事務陷阱 http://www.ibm.com/developerworks/cn/java/j-ts1.html 事務策略: 高并發策略 http://www.ibm.com/developerworks/cn/java/j-ts5/index.html 這是一個系列.

    http://beet.sourceforge.net
    Beet records user behavior and performance data for your Spring-based Java application.? It can thus help you to analyze usage patterns and research production performance issues.
    主站蜘蛛池模板: 国产精品亚洲一区二区三区在线观看| 亚洲成AV人片高潮喷水| 亚洲欧洲日产国码av系列天堂| 国产女高清在线看免费观看| 亚洲伊人久久大香线蕉影院| 亚洲国产综合在线| 污污视频免费观看网站| 男女交性永久免费视频播放 | 国产亚洲午夜高清国产拍精品| 女人18毛片水真多免费播放| 99久久精品免费精品国产| 精品久久久久国产免费| 亚洲国产a级视频| 国产最新凸凹视频免费| 亚洲国产精品无码久久一线 | 四虎成人免费网站在线| 亚洲伊人tv综合网色| 一二三四视频在线观看中文版免费| 久久久国产亚洲精品| 久久久久久久91精品免费观看| 午夜性色一区二区三区免费不卡视频 | 国产免费一区二区视频| 亚洲国产精品无码成人片久久| 日本xxxx色视频在线观看免费| 久久久久久亚洲精品成人| 一个人免费视频观看在线www| 美女羞羞免费视频网站| 在线精品亚洲一区二区| 成年人免费观看视频网站| 青青草a免费线观a| 无码国产精品一区二区免费| 国产精品视频免费观看| 日本在线高清免费爱做网站| 亚洲视频在线免费看| 九一在线完整视频免费观看 | 1000部拍拍拍18勿入免费视频软件 | 含羞草国产亚洲精品岁国产精品| 久久被窝电影亚洲爽爽爽| 亚洲中文字幕无码久久2017| 久久精品亚洲乱码伦伦中文| 亚洲无码在线播放|