Natural

 

spring整合hibernate的dataSource、sessionFactory配置demo

参考链接:
分析共享Spring配置数据源四种方式(附相应jar包)
http://blog.csdn.net/llhhyy1989/article/details/7861212


<?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
="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name
="driverClassName">  
            <value>oracle.jdbc.driver.OracleDriver</value>  
        </property>  
        <property name
="url">  
            <value>jdbc:oracle:thin:@
127.0.0.1:1521:db</value>  
        </property>  
        <property name
="username">  
            <value>root</value>  
        </property>  
        <property name
="password">  
            <value>root</value>  
        </property>  
    </bean> 
    <bean id
="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name
="dataSource" ref="dataSource" />
        <property name
="mappingResources">
            <list>
            <value>com/test/dao/model/A.hbm.xml</value>
            <value>com/test/dao/model/B.hbm.xml</value>
            </list>
        </property>
        <property name
="hibernateProperties">
              <props>
                <prop key
="hibernate.dialect">
                    org.hibernate.dialect.OracleDialect
                </prop>
                <prop key
="hibernate.show_sql">true</prop>
                <prop key
="hibernate.jdbc.batch_size">20</prop>
            </props>
        </property>
      </bean>
    <bean id
="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name
="sessionFactory" ref="sessionFactory" />
      </bean>
    <bean id
="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
        <property name
="transactionManager" ref="transactionManager" />
      </bean>
<beans>

posted on 2012-08-28 19:24 此号已被删 阅读(2651) 评论(0)  编辑  收藏 所属分类: Spring


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(8)

随笔分类(83)

随笔档案(78)

文章档案(2)

相册

收藏夹(7)

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜