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

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

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

    沉睡森林@漂在北京

    本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請注明出處。

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      152 隨筆 :: 4 文章 :: 114 評論 :: 0 Trackbacks

    今天對以前寫的東西進(jìn)行了部分整理,發(fā)現(xiàn)利用spring2.5的注釋事物控制,好像只有一次成功過,那次使用的是JdbcTemplate。但是后來利用hibernate或者ibatis都沒有成功,今天整理了很長時(shí)間,還是沒有配置好。下面是寫的一些xml文件,個(gè)人感覺應(yīng)該沒有什么問題了,疑惑。

     

        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"

           destroy-method="close">

           <property name="driverClassName" value="com.mysql.jdbc.Driver" />

           <property name="url" value="jdbc:mysql://localhost/greatwall" />

           <property name="username" value="root" />

           <property name="password" value="sa" />

        </bean>

       

        <!-- ibatis sqlMapClient config -->

        <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">

           <property name="configLocation">

               <value>classpath:sql\sql-map-config.xml</value>

           </property>

           <property name="dataSource">

               <ref bean="dataSource" />

           </property>

        </bean>

       

        <bean id="transactionManager"

           class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

           <property name="dataSource" ref="dataSource" />

        </bean>

       

        <tx:advice id="txAdvice" transaction-manager="transactionManager">

           <tx:attributes> 

             <!-- all methods starting with 'get' are read-only

               <tx:method name="select*" read-only="true" />  -->

             <!-- other methods use the default transaction settings (see below) -->

               <tx:method name="*" />

           </tx:attributes>

        </tx:advice>

       

        <aop:aspectj-autoproxy /> 

        <aop:config proxy-target-class="true" />

          <!--

        <aop:config proxy-target-class="true" >

           <aop:pointcut id="fooServiceOperation" expression="execution(* com.example.service.ICustomerService.*(..))" />

           <aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation" />

        </aop:config>

        -->

       

        <aop:config proxy-target-class="true" >

           <aop:advisor   pointcut="execution(* com.example.service.ICustomerService.*(..))"  advice-ref="txAdvice" />

        </aop:config>

       

        <bean id="customerDAO" class="com.example.dao.impl.CustomerDAO">

           <property name="sqlClient" ref="sqlMapClient" />

        </bean>

       

       

        <bean id="customerService" class="com.example.service.impl.CustomerService">

           <property name="customerDAO" ref="customerDAO" />

        </bean>

    posted on 2009-02-14 21:48 王總兵 閱讀(820) 評論(2)  編輯  收藏

    評論

    # re: spring事物控制問題整理(1) 2009-02-14 23:40 王兵
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"" target="_new">http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"" target="_new">http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"" target="_new">http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"" target="_new">http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver">
    </property>
    <property name="url" value="jdbc:mysql://localhost:3306/greatwall">
    </property>
    <property name="username" value="root"></property>
    <property name="password" value="sa"></property>
    </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.MySQLDialect
    </prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>com/example/domain/Customer.hbm.xml</value>
    </list>
    </property>
    </bean>



    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="*" />
    <tx:method name="insert*" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>

    <aop:config proxy-target-class="true" />


    <aop:config proxy-target-class="true" >
    <aop:advisor pointcut="execution(* com.example.service.CustomerService.*(..))" advice-ref="txAdvice" />
    </aop:config>

    <bean id="customerDao" class="com.example.dao.impl.CustomerDaoImpl">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>

    <bean id="customerService" class="com.example.service.impl.CustomerServiceImpl">
    <property name="customerDao" ref="customerDao" />
    </bean>


    </beans>  回復(fù)  更多評論
      

    # re: spring事物控制問題整理(1) 2009-02-14 23:42 王兵
    上面的xml配置在hibernate下面可以使用,對于ibatis還沒有配置成功過。郁悶。繼續(xù)利用注釋對hibernate進(jìn)行配置,不過感覺利用AOP還是比較省事,對service的方法進(jìn)行規(guī)范,一個(gè)地方配置解決了一大堆的注釋。  回復(fù)  更多評論
      


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 精品国产亚洲男女在线线电影| 一级做α爱过程免费视频| 久艹视频在线免费观看| 亚洲精品无码MV在线观看| 一级特黄录像免费播放中文版| 国产乱子伦片免费观看中字| 337P日本欧洲亚洲大胆艺术图| 最新69国产成人精品免费视频动漫 | 好久久免费视频高清| 亚洲AV综合色区无码一区爱AV| 爽爽爽爽爽爽爽成人免费观看| 亚洲精品乱码久久久久久按摩| 久久久久国产免费| 综合自拍亚洲综合图不卡区| 人与禽交免费网站视频| 亚洲人成网站999久久久综合| 国产伦精品一区二区三区免费迷 | 午夜亚洲国产成人不卡在线| 一区二区三区视频免费观看| 国产精一品亚洲二区在线播放| 7m凹凸精品分类大全免费| 亚洲H在线播放在线观看H| 免费一级毛片在线播放不收费| a一级毛片免费高清在线| 亚洲一区二区三区四区在线观看| 91成年人免费视频| 男女超爽视频免费播放| 久久精品国产亚洲AV麻豆~| 亚洲人成网站免费播放| 一级毛片免费一级直接观看| 亚洲视频中文字幕| 四虎免费大片aⅴ入口| 国产一二三四区乱码免费 | 亚洲Av永久无码精品黑人 | 亚洲jizzjizz在线播放久| 亚洲A∨午夜成人片精品网站| 黄色网站软件app在线观看免费| 亚洲国产成人精品激情| 国产成人精品日本亚洲专区61| 最近免费视频中文字幕大全| 猫咪免费人成在线网站 |