Spring xml事务配置

来源:互联网 发布:野生动物灭绝数据 编辑:程序博客网 时间:2024/05/12 01:39

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>    
     <!-- SessionFactory -->
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
       <!--<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>-->
         <property name="mappingLocations">
   <list>
             <value>classpath:/com/tpcorp/**/*.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/Staff.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/GroupInfo.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/GroupStaff.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/UserConfig.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/PasswordHistory.hbm.xml</value>
             <value>classpath:/com/tpcorp/system/login/def/InvalidLoginHistory.hbm.xml</value>
         </list> 
         </property>  
         <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    <prop key="show_sql">true</prop>
    <prop key="hibernate.cache.provider_class">  
                    org.hibernate.cache.HashtableCacheProvider   
                </prop>
                <!-- 
                <prop key="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</prop>
    <prop key="hibernate.connection.url">jdbc:oracle:thin:@192.168.1.6:1521:orcl</prop>
    <prop key="hibernate.connection.username">king</prop>
    <prop key="hibernate.connection.password">king</prop>
    -->
                <prop key="hibernate.connection.datasource">java:/michellev7</prop>
               
   </props>
  </property>  
     </bean>
    
     <!-- TransactionManager  -->
    
     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
         <property name="sessionFactory">
             <ref local="sessionFactory"/>
         </property>
     </bean>
    
      <bean id="parentDao"  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <description>All Dao bean's parent bean, define the common sessionFactory property of Dao implements classes</description>
  <property name="sessionFactory" ref="sessionFactory" />
 </bean>
 
  <bean id="transactionProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager" ref="parentDao"></property>
  <property name="transactionAttributes">
   <props>
   <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
   </props>
  </property>
 </bean>

 

<bean id="appDao" class="com.tpcorp.michelle.app.dao.AppDaoImpl" parent="parentDao"/>
 <bean id="exportDao" class="com.tpcorp.michelle.excel.dao.ExportDaoImpl" parent="parentDao"/>
 <bean id="unAppService" class="com.tpcorp.michelle.app.service.AppServiceImpl">
  <property name="appDao" ref="appDao"/>
 </bean>
 <bean id="unExportService" class="com.tpcorp.michelle.excel.service.ExportServiceImpl">
  <property name="exportDao" ref="exportDao"/>
 </bean>
<!-- transaction Service -->
    <bean id="appService" parent="transactionProxy">
  <property name="target" ref="unAppService"></property>
 </bean>
 <bean id="exportService" parent="transactionProxy">
  <property name="target" ref="unExportService"></property>
 </bean>


</beans>

0 0
原创粉丝点击