Spring事务配置

< bean  id ="sessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
        
< property  name ="dataSource" >
            
< ref  local ="dataSource"   />
        
</ property >
    
        
<!--  bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/ -->
    
< bean  id ="transactionManager"  class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
        
< property  name ="sessionFactory" >
            
< ref  local ="sessionFactory"   />
        
</ property >
    
</ bean >

    
<!--  Hibernate Transaction Interceptor Definition  -->
    
< bean  id ="hibernateTransactionInterceptor"
        class
="org.springframework.transaction.interceptor.TransactionInterceptor"
        parent
="transactionIntercetorTemplate" >
        
< property  name ="transactionManager" >
            
< bean  id ="hibernateTransactionManager"
                class
="org.springframework.orm.hibernate3.HibernateTransactionManager" >
                
< property  name ="sessionFactory" >
                    
< ref  bean ="sessionFactory"   />
                
</ property >
            
</ bean >
        
</ property >
    
</ bean >

    
<!--  Transction Intercetor's Template  -->
    
< bean  id ="transactionIntercetorTemplate"  abstract ="true" >
        
< property  name ="transactionAttributes" >
            
< props >
                
< prop  key ="get*" > PROPAGATION_REQUIRED,readOnly </ prop >
                
< prop  key ="is*" > PROPAGATION_REQUIRED,readOnly </ prop >
                
< prop  key ="check*" > PROPAGATION_REQUIRED,readOnly </ prop >
                
< prop  key ="insert*" > PROPAGATION_REQUIRED </ prop >
                
< prop  key ="update*" > PROPAGATION_REQUIRED </ prop >
                
< prop  key ="delete*" > PROPAGATION_REQUIRED,-BussException </ prop >
                
< prop  key ="*" > PROPAGATION_REQUIRED </ prop >
            
</ props >
        
</ property >
    
</ bean >

    
<!--  定义自动代理生成器 -->
    
< bean  id ="autoProxyCreator"
        class
="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" >
        
< property  name ="interceptorNames" >
            
< list >
                
< idref  bean ="hibernateTransactionInterceptor"   />
                
< idref  bean ="jdbcTransactionInterceptor"   />
            
</ list >
        
</ property >
        
< property  name ="beanNames" >
            
< value > *Service </ value >  
            
<!-- list>
                <idref bean="bookService" />                                        
            </list
-->
            
<!-- 添加Service bean -->
        
</ property >
    
</ bean >
    
< bean  id ="hibernateDaoTemplate"  abstract ="true" >
        
< property  name ="sessionFactory" >
            
< ref  bean ="sessionFactory"   />
        
</ property >
    
</ bean >
    
<!--  Dao 定义  -->
    
< bean  id ="imageDao"  class ="com.fbyssssite.dao.ImageDao"
        parent
="hibernateDaoTemplate"   />
    < bean  id ="imageFolderDao"  class ="com.fbyssssite.dao.ImageFolderDao"
        parent
="hibernateDaoTemplate"   />
    
<!--  Service 定义  -->
    
< bean  id ="imageService"  class ="com.fbyssssite.bo.ImageService"  autowire ="byName" >
        
< property  name ="dao"  ref ="imageDao" ></ property >
    
</ bean >     
    < bean  id ="imageFolderService"  class ="com.fbyssssite.bo.ImageFolderService"  autowire ="byName" >
        
< property  name ="dao"  ref ="imageFolderDao" ></ property >
    
</ bean >

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值