yunshichen

我相信人生是值得活的,尽管人在一生中必须遭受痛苦,卑劣,残酷,不幸和死亡的折磨,我依然深信如此.但我认为人生不一定要有意义,只是对一些人而言,他们可以使人生有意义. ---J 赫胥黎

Spring & Hibernate 配置文件

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

< beans >
    
<!--  ========================= RESOURCE DEFINITIONS =========================  -->

    
<!--  This is defualt dababase.  -->
    
< bean  id ="myDataSource"  class ="org.apache.commons.dbcp.BasicDataSource" >
        
< property  name ="driverClassName"  value ="com.mysql.jdbc.Driver"   />
        
< property  name ="url"  value ="jdbc:mysql://localhost:3306/test"   />
        
< property  name ="username"  value ="root"   />
        
< property  name ="password"  value ="root"   />
    
</ bean >

     
     
< bean  id ="transactionManager"  class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
       
< property  name ="sessionFactory"  ref ="mySessionFactory" />
    
</ bean >
     
    
< bean  id ="transactionInterceptor"
        class
="org.springframework.transaction.interceptor.TransactionInterceptor" >
        
< property  name ="transactionManager"  ref ="transactionManager"   />
        
< property  name ="transactionAttributes" >
            
< props >
                
< prop  key ="create*" >
                    PROPAGATION_REQUIRED,-ServiceException,+DaoException
                
</ prop >
                
< prop  key ="update*" >
                    PROPAGATION_REQUIRED,-ServiceException,+DaoException
                
</ prop >
                
< prop  key ="delete*" >
                    PROPAGATION_REQUIRED,-ServiceException,+DaoException
                
</ prop >
                
< prop  key ="get*" > PROPAGATION_REQUIRED,readOnly </ prop >
            
</ props >
        
</ property >
    
</ bean >


    
<!--  find all persistence ,add transactions on them.  -->
    
< bean
        
class ="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" >
        
< property  name ="beanNames" >
            
< value > *Dao </ value >
        
</ property >
        
< property  name ="interceptorNames" >
            
< list >
                
<!-- <value>dataSourceSwitchIntercetor</value> -->
                
< value > transactionInterceptor </ value >
            
</ list >
        
</ property >
    
</ bean >


</ beans >

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

< beans >

    
< bean  id ="mySessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
        
< property  name ="dataSource"  ref ="myDataSource"   />
        
< property  name ="mappingResources" >
            
< list >
                
< value > /sample/dao/bank/hibernate/Money.hbm.xml </ value >
            
</ list >
        
</ property >
        
< property  name ="hibernateProperties" >
            
< props >
                
< prop  key ="hibernate.dialect" > org.hibernate.dialect.MySQLDialect </ prop >
                
< prop  key ="hibernate.hbm2ddl.auto" > update </ prop >
                
< prop  key ="hibernate.jdbc.batch_size" > 0 </ prop >
                
< prop  key ="hibernate.show_sql" > true </ prop >
                
< prop  key ="hibernate.format_sql" > true </ prop >
            
</ props >
        
</ property >
    
</ bean >

    
<!--  Provides a super class for dao.  -->
    
< bean  id ="genericDaoParent"  class ="ww.support.dao.GenericDao" >
        
< property  name ="sessionFactory"  ref ="mySessionFactory"   />         
    
</ bean >
    
    
< bean  id ="moneyDao"  class ="sample.dao.bank.hibernate.MoneyDao"  parent  ="genericDaoParent" >
        
< property  name ="hbmObject"  value ="Money"   />
    
</ bean >



</ beans >

posted on 2008-07-03 10:26 Chenyunshi 阅读(393) 评论(0)  编辑 收藏 引用 所属分类: Java

只有注册用户登录后才能发表评论。
<2008年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿(7)

随笔分类

随笔档案

文章分类

相册

搜索

最新评论

阅读排行榜

评论排行榜