<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 閱讀(217) 評論(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>

    主站蜘蛛池模板: 日本免费一二区在线电影| 青青青国产手机频在线免费观看| 97视频热人人精品免费| 亚洲天天在线日亚洲洲精| 永久免费av无码入口国语片| 国产亚洲精品无码专区| a毛片免费全部在线播放**| 国产V亚洲V天堂无码久久久| 人人揉揉香蕉大免费不卡| 久久亚洲sm情趣捆绑调教 | 国产猛男猛女超爽免费视频| 亚洲精品字幕在线观看| 久久久久国产精品免费看| 99人中文字幕亚洲区| 手机看黄av免费网址| 亚洲精品第一国产综合亚AV| 成人爱做日本视频免费| caoporm超免费公开视频| 久久久亚洲精品国产| 一二三四在线观看免费高清中文在线观看 | 亚洲AV无码一区二区乱子伦| 久久精品无码专区免费东京热| 亚洲人成在线免费观看| 日韩成人免费在线| 国产成人精品免费视频大全| 亚洲国产综合91精品麻豆| 成人黄软件网18免费下载成人黄18免费视频 | 国产不卡免费视频| 99热在线日韩精品免费| 亚洲天堂一区二区三区四区| 尤物永久免费AV无码网站| 永久免费不卡在线观看黄网站| 中国china体内裑精亚洲日本| 亚洲国产精品一区二区第一页免| 99久久免费国产精品热| 亚洲AV色吊丝无码| 国产亚洲日韩一区二区三区| 97国产免费全部免费观看| 成人在线免费视频| 黄色短视频免费看| 国产成人亚洲精品91专区手机|