加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Spring3 整合Hibernate3.5 动态切换SessionFactory (切换数据库

发布时间:2020-12-15 01:51:41 所属栏目:大数据 来源:网络整理
导读:上一篇文章介绍到了怎么样在Sping、MyBatis、Hibernate整合的应用中动态切换DataSource数据源的方法,但最终遗留下一个问题: 不能切换数据库方言 。数据库方言可能在当前应用的架构中意义不是很大,但是如果单纯用MyBatis或Hibernate做数据库持久化操作,还

上一篇文章介绍到了怎么样在Sping、MyBatis、Hibernate整合的应用中动态切换DataSource数据源的方法,但最终遗留下一个问题:不能切换数据库方言。数据库方言可能在当前应用的架构中意义不是很大,但是如果单纯用MyBatis或Hibernate做数据库持久化操作,还是要处理这一问题。

那么下面将介绍怎么样动态切换SessionFactory,为什么要切换SessionFactory?

因为这里切换SessionFactory就可以实现多数据源和多个SessionFactory,每个SessionFactory有自己独立的数据库配置和SessionFactory的相关配置。我们的数据库方言就配置在SessionFactory这里,所以实现了切换SessionFactory也就实现了切换数据库方言的问题。这个主要是针对Hibernate来操作的,而MyBatis则需要动态切换SqlSessionFactory才行。

1、定义全局切换SessionFactory的工具

com.hoo.framework.spring.support;
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;?</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;/**</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * <b>function:</b> 多数据源</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @author hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @createDate 2013-9-27 上午11:36:57</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @file CustomerContextHolder.java</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @package com.hoo.framework.spring.support</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @project SHMB</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @blog http://blog.csdn.net/IBM_hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @email hoojo_@126.com</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @version 1.0</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; */</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;abstract</span> <span style="color: #0000ff"&gt;class</span> CustomerContextHolder {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;?</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;final</span> <span style="color: #0000ff"&gt;static</span> String SESSION_FACTORY_MYSQL = <span style="color: #006080"&gt;"mysql"</span>;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;final</span> <span style="color: #0000ff"&gt;static</span> String SESSION_FACTORY_ORACLE = <span style="color: #006080"&gt;"oracle"</span>;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;private</span> <span style="color: #0000ff"&gt;static</span> <span style="color: #0000ff"&gt;final</span> ThreadLocal<String> contextHolder = <span style="color: #0000ff"&gt;new</span> ThreadLocal<String>();  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;static</span> <span style="color: #0000ff"&gt;void</span> setCustomerType(String customerType) {  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        contextHolder.set(customerType);  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    }  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;      </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;static</span> String getCustomerType() {  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> contextHolder.get();  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;static</span> <span style="color: #0000ff"&gt;void</span> clearCustomerType() {  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        contextHolder.remove();  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;}</pre>

同样上面的静态变量和前一文章中介绍的一致,它需要和下面配置文件中的SessionFactory的key对应。

2、实现自己的SessionFactory

定义好接口

<p id="codeSnippetWrapper">

com.hoo.framework.spring.support.core;
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.SessionFactory;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * <b>function:</b> 动态SessionFactory接口</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @createDate 2013-10-12 下午03:29:52</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @file DynamicSessionFactory.java</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @package com.hoo.framework.spring.support.core</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;interface</span> DynamicSessionFactory <span style="color: #0000ff"&gt;extends</span> SessionFactory {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> SessionFactory getHibernateSessionFactory();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;}</pre>

实现接口

<p id="codeSnippetWrapper">

java.io.Serializable;
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> java.sql.Connection;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> java.util.Map;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> java.util.Set;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> javax.naming.NamingException;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> javax.naming.Reference;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.Cache;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.HibernateException;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.Interceptor;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.SessionFactory;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.StatelessSession;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.TypeHelper;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.classic.Session;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.engine.FilterDefinition;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.metadata.ClassMetadata;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.metadata.CollectionMetadata;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.hibernate.stat.Statistics;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> com.hoo.framework.spring.support.CustomerContextHolder;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;/**</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * <b>function:</b> 动态数据源实现</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @author hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @createDate 2013-10-12 下午03:31:31</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @file DynamicSessionFactoryImpl.java</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @package com.hoo.framework.spring.support.core</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @project SHMB</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @blog http://blog.csdn.net/IBM_hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @email hoojo_@126.com</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @version 1.0</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; */</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;@SuppressWarnings({ <span style="color: #006080"&gt;"unchecked"</span>,<span style="color: #006080"&gt;"deprecation"</span> })</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;class</span> DynamicSessionFactoryImpl <span style="color: #0000ff"&gt;implements</span> DynamicSessionFactory {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;private</span> <span style="color: #0000ff"&gt;static</span> <span style="color: #0000ff"&gt;final</span> <span style="color: #0000ff"&gt;long</span> serialVersionUID = 5384069312247414885L;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;private</span> Map<Object,SessionFactory> targetSessionFactorys;  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;private</span> SessionFactory defaultTargetSessionFactory; </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;/**</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @see com.hoo.framework.spring.support.core.DynamicSessionFactory#getHibernateSessionFactory()</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * <b>function:</b> 重写这个方法,这里最关键</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @author hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @createDate 2013-10-18 上午10:45:25</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     */</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    @Override</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> SessionFactory getHibernateSessionFactory() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        SessionFactory targetSessionFactory = targetSessionFactorys.get(CustomerContextHolder.getCustomerType());  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;if</span> (targetSessionFactory != null) {  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;return</span> targetSessionFactory;  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        } <span style="color: #0000ff"&gt;else</span> <span style="color: #0000ff"&gt;if</span> (defaultTargetSessionFactory != null) {  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;return</span> defaultTargetSessionFactory;  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        }  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> null;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    }</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> close() <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().close();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    @Override</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;boolean</span> containsFetchProfileDefinition(String s) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().containsFetchProfileDefinition(s);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    }</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evict(Class clazz) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evict(clazz);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evict(Class clazz,Serializable serializable) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evict(clazz,serializable);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictCollection(String s) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictCollection(s);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictCollection(String s,monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictCollection(s,monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictEntity(String entity) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictEntity(entity);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictEntity(String entity,monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictEntity(entity,monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictQueries() <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictQueries();        </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> evictQueries(String queries) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().evictQueries(queries);        </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Map<String,ClassMetadata> getAllClassMetadata() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getAllClassMetadata();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Map getAllCollectionMetadata() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getAllClassMetadata();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Cache getCache() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getCache();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> ClassMetadata getClassMetadata(Class clazz) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getClassMetadata(clazz);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> ClassMetadata getClassMetadata(String classMetadata) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getClassMetadata(classMetadata);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> CollectionMetadata getCollectionMetadata(String collectionMetadata) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getCollectionMetadata(collectionMetadata);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Session getCurrentSession() <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getCurrentSession();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Set getDefinedFilterNames() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getDefinedFilterNames();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> FilterDefinition getFilterDefinition(String definition) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getFilterDefinition(definition);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Statistics getStatistics() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getStatistics();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> TypeHelper getTypeHelper() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getTypeHelper();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;boolean</span> isClosed() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().isClosed();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Session openSession() <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openSession();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Session openSession(Interceptor interceptor) <span style="color: #0000ff"&gt;throws</span> HibernateException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openSession(interceptor);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Session openSession(Connection connection) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openSession(connection);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Session openSession(Connection connection,Interceptor interceptor) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openSession(connection,interceptor);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> StatelessSession openStatelessSession() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openStatelessSession();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> StatelessSession openStatelessSession(Connection connection) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().openStatelessSession(connection);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> Reference getReference() <span style="color: #0000ff"&gt;throws</span> NamingException {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> <span style="color: #0000ff"&gt;this</span>.getHibernateSessionFactory().getReference();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> setTargetSessionFactorys(Map<Object,SessionFactory> targetSessionFactorys) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.targetSessionFactorys = targetSessionFactorys;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> setDefaultTargetSessionFactory(SessionFactory defaultTargetSessionFactory) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;this</span>.defaultTargetSessionFactory = defaultTargetSessionFactory;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;}</pre>

上面最重要的就是getHibernateSessionFactory重写这个方法,其他方法和原来实现的无异。重写这个方法后利用CustomerContextHolder动态设置SessionFactory类型就可以动态的切换SessionFactory。

3、动态的事务管理器,因为我们这里是动态切换SessionFactory,所以事务这块也需要动态切换SessionFactory来完成事务的操作。

<p id="codeSnippetWrapper">

com.hoo.framework.spring.support.tx;
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> javax.sql.DataSource;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.springframework.orm.hibernate3.HibernateTransactionManager;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> org.springframework.orm.hibernate3.SessionFactoryUtils;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;import</span> com.hoo.framework.spring.support.core.DynamicSessionFactory;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * <b>function:</b> 重写HibernateTransactionManager事务管理器,实现自己的动态的事务管理器</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @createDate 2013-10-12 下午03:54:02</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @file DynamicTransactionManager.java</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt; * @package com.hoo.framework.spring.support.tx</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;class</span> DynamicTransactionManager <span style="color: #0000ff"&gt;extends</span> HibernateTransactionManager {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;private</span> <span style="color: #0000ff"&gt;static</span> <span style="color: #0000ff"&gt;final</span> <span style="color: #0000ff"&gt;long</span> serialVersionUID = -4655721479296819154L;</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;/** </span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @see org.springframework.orm.hibernate4.HibernateTransactionManager#getDataSource()</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * <b>function:</b> 重写</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @author hoojo</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @createDate 2013-10-12 下午03:55:24</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     */</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> DataSource getDataSource() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> SessionFactoryUtils.getDataSource(getSessionFactory());</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;/** </span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @see org.springframework.orm.hibernate4.HibernateTransactionManager#getSessionFactory()</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * <b>function:</b> 重写</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #008000"&gt;     * @createDate 2013-10-12 下午03:55:24</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;public</span> SessionFactory getSessionFactory() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        DynamicSessionFactory dynamicSessionFactory = (DynamicSessionFactory) <span style="color: #0000ff"&gt;super</span>.getSessionFactory();  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        SessionFactory hibernateSessionFactory = dynamicSessionFactory.getHibernateSessionFactory();  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;return</span> hibernateSessionFactory;  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;}</pre>

这里主要重写getDataSource()/getSessionFactory()这两个方法,getSessionFactory方法是利用我们上面定义的接口来动态获取我们在上下文(CustomerContextHolder)中定义切换的SessionFactory对象。而getDataSource则是获得动态SessionFactory的DataSource,这里也不难理解。

4、至此,重写的接口和实现都完成,下面开始配置相关的代码

<p id="codeSnippetWrapper">

?
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;beans</span> <span style="color: #ff0000"&gt;xmlns</span><span style="color: #0000ff"&gt;="http://www.springframework.org/schema/beans"</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #ff0000"&gt;xmlns:aop</span><span style="color: #0000ff"&gt;="http://www.springframework.org/schema/aop"</span> </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #ff0000"&gt;xmlns:tx</span><span style="color: #0000ff"&gt;="http://www.springframework.org/schema/tx"</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #ff0000"&gt;xmlns:xsi</span><span style="color: #0000ff"&gt;="http://www.w3.org/2001/XMLSchema-instance"</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #ff0000"&gt;xsi:schemaLocation</span><span style="color: #0000ff"&gt;="http://www.springframework.org/schema/beans </span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    http://www.springframework.org/schema/aop </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    http://www.springframework.org/schema/tx  </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd "<span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- 配置c3p0数据源 --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="dataSourceOracle"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="com.mchange.v2.c3p0.ComboPooledDataSource"</span> <span style="color: #ff0000"&gt;destroy-method</span><span style="color: #0000ff"&gt;="close"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="driverClass"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${datasource.driver}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="jdbcUrl"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${datasource.url}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="user"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${datasource.username}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="password"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${datasource.password}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="acquireIncrement"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.acquireIncrement}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="initialPoolSize"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.initialPoolSize}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="minPoolSize"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.minPoolSize}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="maxPoolSize"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.maxPoolSize}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="maxIdleTime"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.maxIdleTime}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="idleConnectionTestPeriod"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.idleConnectionTestPeriod}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="maxStatements"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.maxStatements}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="numHelperThreads"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.numHelperThreads}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="preferredTestQuery"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.preferredTestQuery}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="testConnectionOnCheckout"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="${c3p0.testConnectionOnCheckout}"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;bean</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="dataSourceMySQL"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="com.mchange.v2.c3p0.ComboPooledDataSource"</span> <span style="color: #ff0000"&gt;destroy-method</span><span style="color: #0000ff"&gt;="close"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="driverClass"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="com.mysql.jdbc.Driver"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="jdbcUrl"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="jdbc:mysql://172.31.108.178:3306/world?useUnicode=true&amp;amp;characterEncoding=UTF-8&amp;amp;zeroDateTimeBehavior=convertToNull"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="user"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="root"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="password"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="jp2011"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- Annotation 配置sessionFactory,配置数据库连接,注入hibernate数据库配置 --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="mySQLSessionFactory"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="dataSource"</span> <span style="color: #ff0000"&gt;ref</span><span style="color: #0000ff"&gt;="dataSourceMySQL"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="packagesToScan"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="com.hoo.**.mysqlentity"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="annotatedClasses"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;array</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;value</span><span style="color: #0000ff"&gt;></span>com.hoo.common.entity.IDGenerator<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;value</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;array</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;property</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="hibernateProperties"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;props</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;prop</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="hibernate.dialect"</span><span style="color: #0000ff"&gt;></span>org.hibernate.dialect.MySQLDialect<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;prop</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #008000"&gt;<!-- 链接释放策略 on_close | after_transaction | after_statement | auto  --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;prop</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="hibernate.connection.release_mode"</span><span style="color: #0000ff"&gt;></span>after_transaction<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;prop</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;prop</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="hibernate.show_sql"</span><span style="color: #0000ff"&gt;></span>true<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;prop</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;prop</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="hibernate.format_sql"</span><span style="color: #0000ff"&gt;></span>true<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;prop</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;props</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;property</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="oracleSessionFactory"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="dataSource"</span> <span style="color: #ff0000"&gt;ref</span><span style="color: #0000ff"&gt;="dataSourceOracle"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="packagesToScan"</span> <span style="color: #ff0000"&gt;value</span><span style="color: #0000ff"&gt;="com.hoo.**.entity"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="hibernateProperties"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;props</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;prop</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="hibernate.dialect"</span><span style="color: #0000ff"&gt;></span>org.hibernate.dialect.OracleDialect<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;prop</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #008000"&gt;<!--prop key="hibernate.hbm2ddl.auto"&gt;update</prop--></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;props</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;bean</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- 动态SessionFactory --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="sessionFactory"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="com.hoo.framework.spring.support.core.DynamicSessionFactoryImpl"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="defaultTargetSessionFactory"</span> <span style="color: #ff0000"&gt;ref</span><span style="color: #0000ff"&gt;="oracleSessionFactory"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="targetSessionFactorys"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;map</span><span style="color: #0000ff"&gt;></span>     </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;entry</span> <span style="color: #ff0000"&gt;value-ref</span><span style="color: #0000ff"&gt;="oracleSessionFactory"</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="oracle"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;                <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;entry</span> <span style="color: #ff0000"&gt;value-ref</span><span style="color: #0000ff"&gt;="mySQLSessionFactory"</span> <span style="color: #ff0000"&gt;key</span><span style="color: #0000ff"&gt;="mysql"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;map</span><span style="color: #0000ff"&gt;></span> </pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- 自定义动态切换SessionFactory事务管理器,注入sessionFactory  --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;bean</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="transactionManager"</span> <span style="color: #ff0000"&gt;class</span><span style="color: #0000ff"&gt;="com.hoo.framework.spring.support.tx.DynamicTransactionManager"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;property</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="sessionFactory"</span> <span style="color: #ff0000"&gt;ref</span><span style="color: #0000ff"&gt;="sessionFactory"</span> <span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- 配置事务的传播特性 --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:advice</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="txAdvice"</span> <span style="color: #ff0000"&gt;transaction-manager</span><span style="color: #0000ff"&gt;="transactionManager"</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:attributes</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:method</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="add*"</span> <span style="color: #ff0000"&gt;propagation</span><span style="color: #0000ff"&gt;="REQUIRED"</span> <span style="color: #ff0000"&gt;rollback-for</span><span style="color: #0000ff"&gt;="java.lang.Exception"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:method</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="edit*"</span> <span style="color: #ff0000"&gt;propagation</span><span style="color: #0000ff"&gt;="REQUIRED"</span> <span style="color: #ff0000"&gt;rollback-for</span><span style="color: #0000ff"&gt;="java.lang.Exception"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:method</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="remove*"</span> <span style="color: #ff0000"&gt;propagation</span><span style="color: #0000ff"&gt;="REQUIRED"</span> <span style="color: #ff0000"&gt;rollback-for</span><span style="color: #0000ff"&gt;="java.lang.Exception"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:method</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="execute*"</span> <span style="color: #ff0000"&gt;propagation</span><span style="color: #0000ff"&gt;="REQUIRED"</span> <span style="color: #ff0000"&gt;rollback-for</span><span style="color: #0000ff"&gt;="java.lang.Exception"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;            <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;tx:method</span> <span style="color: #ff0000"&gt;name</span><span style="color: #0000ff"&gt;="*"</span> <span style="color: #ff0000"&gt;read-only</span><span style="color: #0000ff"&gt;="true"</span> <span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;tx:attributes</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;tx:advice</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;<!-- 配置那些类、方法纳入到事务的管理 --></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;aop:config</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;aop:pointcut</span> <span style="color: #ff0000"&gt;expression</span><span style="color: #0000ff"&gt;="execution(* com.hoo.**.service.impl.*.*(..))"</span> <span style="color: #ff0000"&gt;id</span><span style="color: #0000ff"&gt;="transactionManagerMethod"</span><span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        <span style="color: #0000ff"&gt;<</span><span style="color: #800000"&gt;aop:advisor</span> <span style="color: #ff0000"&gt;advice-ref</span><span style="color: #0000ff"&gt;="txAdvice"</span> <span style="color: #ff0000"&gt;pointcut-ref</span><span style="color: #0000ff"&gt;="transactionManagerMethod"</span> <span style="color: #0000ff"&gt;/></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;aop:config</span><span style="color: #0000ff"&gt;></span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;</</span><span style="color: #800000"&gt;beans</span><span style="color: #0000ff"&gt;></span></pre>

配置也和我们之前的配置差不多,就是事务管理器部分注入的SessionFactory是我们自己定义的。

5、简单测试

<p id="codeSnippetWrapper">

  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;<span style="color: #0000ff"&gt;public</span> <span style="color: #0000ff"&gt;void</span> testAdd() {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #008000"&gt;// 主要就是这行代码 它才是完成SessionFactory的切换</span></pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    CustomerContextHolder.setCustomerType(CustomerContextHolder.SESSION_FACTORY_MYSQL);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    DeviceInfo entity = <span style="color: #0000ff"&gt;new</span> DeviceInfo();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    entity.setSbbh(System.currentTimeMillis() + <span style="color: #006080"&gt;""</span>);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    entity.setIpdz(<span style="color: #006080"&gt;"my ip address2"</span>);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    entity.setJd(1234);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    <span style="color: #0000ff"&gt;try</span> {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        service.add(entity);</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;    } <span style="color: #0000ff"&gt;catch</span> (Exception e) {</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;        e.printStackTrace();</pre>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 10pt; overflow: visible; padding-top: 0px"&gt;}</pre>

经过测试发现可以查询数据,利用hibernate查询分页也可以生成对应数据库的分页语句。同样在服务层的方法中添加完操作后,特意抛出一个异常,数据也能正常回滚操作,所以DynamicTransactionManager也是起到了该有的作用!

这里我的测试用例是手动切换CustomerContextHolder.setCustomerType的,但实际开发中我们还是得用Spring的Aop中的Interceptor进行切面编程,完成动态切换SessionFactory。上一篇文章已经提到了(读者可以参考该篇博文中的第二节的3、7小节DataSourceMethodInterceptor MultipleDataSourceInterceptor),这里就不再赘述!

上述的实现如果在使用不当的情况下,在实际开发中很可能存在一些问题!

问题1是这样的,通常事务是在Service这层完成,这个应该是没有异议。倘若是这样的话,问题便出现了。而通常我们在MVC中的视图层中仅仅会调用Service中一个方法来完成所有当前业务的处理。如果这个Service中同时操作dbA、dbB两个数据库,事务提交的时候是用哪个数据库的事务呢?

四、总结

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读