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 此號已被刪 閱讀(2673) 評論(0)  編輯  收藏 所屬分類: Spring


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(8)

          隨筆分類(83)

          隨筆檔案(78)

          文章檔案(2)

          相冊

          收藏夾(7)

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 临汾市| 建瓯市| 澄江县| 缙云县| 常山县| 黔西县| 万源市| 新河县| 汕尾市| 汾西县| 锡林浩特市| 淄博市| 普安县| 陇川县| 阿拉尔市| 从化市| 正安县| 阳新县| 邵武市| 丰镇市| 海安县| 高平市| 彭水| 原平市| 三江| 海南省| 阆中市| 鸡东县| 深泽县| 务川| 平舆县| 安达市| 曲靖市| 丰宁| 渝中区| 晋中市| 射阳县| 河源市| 武胜县| 巴塘县| 石屏县|