SSH整合四

来源:互联网 发布:网络棋牌游戏开发 编辑:程序博客网 时间:2024/05/22 00:26
 

11、在applicationContext中配置事务:

<!-- 进行事务处理 -->

<bean id="transactionManager"

       class="org.springframework.orm.hibernate3.HibernateTransactionManager">

       <property name="sessionFactory">

             <ref local="sessionFactory"/>

       </property>     

</bean>

<!-- 进行DAO代理 -->

<bean id="userDaoProxy"

      class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

      <property name="transactionManager">

           <ref local="transactionManager"/>

      </property>

      <property name="target">

           <ref local="deptDAOImpl"/>

      </property>

      <!-- 如果没有事务就新建一个事务 -->

      <property name="transactionAttributes">

           <props>

               <prop key="*">PROPAGATION_REQUIRED</prop> 

           </props>

       </property>

      

      </bean>

原创粉丝点击