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

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

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

    posts - 3, comments - 15, trackbacks - 0, articles - 26
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    spring-framework-1.2.6-chapter8

    Posted on 2005-12-30 19:49 morcble的blog 閱讀(215) 評論(0)  編輯  收藏 所屬分類: Spring

    8.2. Transaction strategies
    1。使用SPRING平臺事務管理器

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    </bean>
    The PlatformTransactionManager definition will look like this:
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    </bean>

    使用JTA事務管理器
    If we use JTA, as in the dataAccessContext-jta.xml file from the same sample application, we need to use a
    container DataSource, obtained via JNDI, and a JtaTransactionManager implementation. The
    JtaTransactionManager doesn't need to know about the DataSource, or any other specific resources, as it will
    use the container's global transaction management.

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/jpetstore"/>>
    </bean>
    <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>

    以上兩種方法實現的功能是等效的。

    2。把hibernate和spring結合起來
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
           <list>
               <value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>
           </list>
        </property>
        <property name="hibernateProperties">
           <props>
               <prop key="hibernate.dialect">${hibernate.dialect}</prop>
           </props>
        </property>
    </bean>
    <bean id="txManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">①(局部事務)
         <property name="sessionFactory" ref="sessionFactory"/>
    </bean>


    ①處With Hibernate and JTA transactions we could simply use the JtaTransactionManager as with JDBC or any
    other resource strategy.
    <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>(JTA為全局事務)


    聲明式事務管理
    <!-- this example is in verbose form, see note later about concise for multiple proxies! -->
    <!-- the target bean to wrap transactionally -->
    <bean id="petStoreTarget">
     ...
    </bean>
    <bean id="petStore" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
     <property name="transactionManager" ref="txManager"/>
     <property name="target" ref="petStoreTarget"/>
     <property name="transactionAttributes">
       <props>
          <prop key="insert*">PROPAGATION_REQUIRED,-MyCheckedException</prop>
          <prop key="update*">PROPAGATION_REQUIRED</prop>
          <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
       </props>
     </property>
    </bean>

    主站蜘蛛池模板: 亚洲午夜一区二区电影院| 亚洲国产精品一区二区九九| 久久综合九九亚洲一区| 精品国产一区二区三区免费| 亚洲精品无码高潮喷水在线| a级毛片免费全部播放无码| 亚洲一区视频在线播放| 亚洲五月午夜免费在线视频| 国产亚洲A∨片在线观看| 免费视频精品一区二区三区| 亚洲一区二区电影| 中文字幕乱码免费视频| 亚洲精品免费网站| 国产精品久久免费视频| 一级美国片免费看| 亚洲国产成人精品无码区在线观看 | 一级毛片全部免费播放| 亚洲视频网站在线观看| 无码国产精品久久一区免费| 亚洲国产成人手机在线观看| 亚洲人AV永久一区二区三区久久| 国产精品小视频免费无限app | 亚洲成?Ⅴ人在线观看无码| 免费无码国产在线观国内自拍中文字幕 | 亚洲AV无码乱码在线观看代蜜桃| 成年女人毛片免费观看97| 美女黄色毛片免费看| 亚洲精品无码久久久久| 国产精品色拉拉免费看| 国产精品亚洲一区二区三区| 亚洲理论电影在线观看| 久久国产免费福利永久| 亚洲6080yy久久无码产自国产| 国产成人精品久久亚洲高清不卡 | 黄色网站软件app在线观看免费| 亚洲欧洲高清有无| 国产视频精品免费| 日韩电影免费在线观看中文字幕| 亚洲免费黄色网址| 亚洲综合色区在线观看| 久久久高清免费视频|