<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[Spring.Net &amp; NHibernate 技术中文站]]></title> 
<description><![CDATA[志立于Spring.NET技术在中国的发展应用。]]></description>
<link>http://www.springframework.cn/blog</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>

<item>
	<title>未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息</title>
	<link>http://www.springframework.cn/blog/?post=26</link>
	<description><![CDATA[<div id="read_tpc" class="tpc_content"><span style="background-color: #c0c0c0">未能找到元素&ldquo;urn:nhibernate-mapping-2.0:hibernate-mapping&rdquo;的架构信息。 &nbsp; , &nbsp; (2, &nbsp; 2)处发生了错误。 &nbsp; <br />
说明: &nbsp; 执行当前 &nbsp; Web &nbsp; 请求期间，出现未处理的异常。请检查堆栈跟踪信息，以了解有关该错误以及代码中导致错误的出处的详细信息。 &nbsp; <br />
<br />
异常详细信息: &nbsp; System.Xml.Schema.XmlSchemaException: &nbsp; 未能找到元素&ldquo;urn:nhibernate-mapping-2.0:hibernate-mapping&rdquo;的架构信息。 &nbsp; , &nbsp; (2, &nbsp; 2)处发生了错误。 <br />
<br />
源错误: &nbsp; <br />
<br />
<br />
行 &nbsp; 40： &nbsp; cfg &nbsp; = &nbsp; new &nbsp; Configuration(); <br />
行 &nbsp; 41： &nbsp; <br />
行 &nbsp; 42： &nbsp; cfg.AddAssembly(AssemblyName); <br />
行 &nbsp; 43： &nbsp; <br />
行 &nbsp; 44： &nbsp; sessions &nbsp; = &nbsp; cfg.BuildSessionFactory(); <br />
<br />
<br />
<br />
XmlSchemaException: &nbsp; 未能找到元素&ldquo;urn:nhibernate-mapping-2.0:hibernate-mapping&rdquo;的架构信息。 &nbsp; , &nbsp; (2, &nbsp; 2)处发生了错误。] <br />
<br />
[MappingException: &nbsp; NHibernateWebDemo.Model.User.hbm.xml(2,2): &nbsp; XML &nbsp; validation &nbsp; error: &nbsp; 未能找到元素&ldquo;urn:nhibernate-mapping-2.0:hibernate-mapping&rdquo;的架构信息。 &nbsp; , &nbsp; (2, &nbsp; 2)处发生了错误。] <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.LogAndThrow(MappingException &nbsp; me) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.ValidationHandler(Object &nbsp; o, &nbsp; ValidationEventArgs &nbsp; args) <br />
&nbsp; &nbsp; System.Xml.Schema.ValidationEventHandler.Invoke(Object &nbsp; sender, &nbsp; ValidationEventArgs &nbsp; e) &nbsp; +0 <br />
&nbsp; &nbsp; System.Xml.Schema.Validator.SendValidationEvent(XmlSchemaException &nbsp; e, &nbsp; XmlSeverityType &nbsp; severity) <br />
&nbsp; &nbsp; System.Xml.Schema.Validator.SendValidationEvent(String &nbsp; code, &nbsp; String &nbsp; msg, &nbsp; XmlSeverityType &nbsp; severity) <br />
&nbsp; &nbsp; System.Xml.Schema.Validator.ProcessElement() <br />
&nbsp; &nbsp; System.Xml.Schema.Validator.Validate() <br />
&nbsp; &nbsp; System.Xml.Schema.Validator.Validate(ValidationType &nbsp; valType) &nbsp; +34 <br />
&nbsp; &nbsp; System.Xml.XmlValidatingReader.ReadWithCollectTextToken() &nbsp; +504 <br />
&nbsp; &nbsp; System.Xml.XmlValidatingReader.Read() &nbsp; +26 <br />
&nbsp; &nbsp; System.Xml.XmlLoader.LoadCurrentNode() &nbsp; +157 <br />
&nbsp; &nbsp; System.Xml.XmlLoader.LoadDocSequence(XmlDocument &nbsp; parentDoc) &nbsp; +49 <br />
&nbsp; &nbsp; System.Xml.XmlLoader.Load(XmlDocument &nbsp; doc, &nbsp; XmlReader &nbsp; reader, &nbsp; Boolean &nbsp; preserveWhitespace) &nbsp; +102 <br />
&nbsp; &nbsp; System.Xml.XmlLoad(XmlReader &nbsp; reader) &nbsp; +72 <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.LoadMappingDocument(XmlTextReader &nbsp; hbmReader, &nbsp; String &nbsp; name) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader &nbsp; hbmReader, &nbsp; String &nbsp; name) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddInputStream(Stream &nbsp; xmlInputStream, &nbsp; String &nbsp; name) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddResource(String &nbsp; path, &nbsp; Assembly &nbsp; assembly) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddResources(Assembly &nbsp; assembly, &nbsp; IList &nbsp; resources, &nbsp; Boolean &nbsp; skipOrdering) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddAssembly(Assembly &nbsp; assembly, &nbsp; Boolean &nbsp; skipOrdering) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddAssembly(Assembly &nbsp; assembly) <br />
&nbsp; &nbsp; NHibernate.Cfg.Configuration.AddAssembly(String &nbsp; assemblyName) <br />
&nbsp; &nbsp; NHibernateWebDemo.DAL.SessionFactory.BuildSessionFactory(String &nbsp; AssemblyName) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\dal\sessionfactory.cs:42 <br />
&nbsp; &nbsp; NHibernateWebDemo.DAL.SessionFactory.OpenSession(String &nbsp; AssemblyName) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\dal\sessionfactory.cs:31 <br />
&nbsp; &nbsp; NHibernateWebDemo.DAL.EntityControl.GetEntities(String &nbsp; strHQL) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\dal\entitycontrol.cs:95 <br />
&nbsp; &nbsp; NHibernateWebDemo.DAL.UserDAL.GetAllUsers(String &nbsp; strHQL) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\dal\userdal.cs:35 <br />
&nbsp; &nbsp; NHibernateWebDemo.BLL.UserBLL.GetAllUsers(String &nbsp; strHQL) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\bll\userbll.cs:33 <br />
&nbsp; &nbsp; NHibernateWebDemo.Web.UserManager.DataGridBind() &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\web\usermanager.aspx.cs:141 <br />
&nbsp; &nbsp; NHibernateWebDemo.Web.UserManager.Page_Load(Object &nbsp; sender, &nbsp; EventArgs &nbsp; e) &nbsp; in &nbsp; c:\inetpub\wwwroot\nhibernatewebdemo\web\usermanager.aspx.cs:39 <br />
&nbsp; &nbsp; System.Web.UI.Control.(EventArgs &nbsp; e) <br />
&nbsp; &nbsp; System.Web.UI.Control.LoadRecursive() <br />
&nbsp; &nbsp; System.Web.UI.Page.ProcessRequestMain() <br />
<br />
<br />
这个问题 很郁闷。。 我配的第一个Nhibernate 也是出现这样的问题。。。 <br />
后来我把2.0改2.2 &nbsp; webconfig里面改1.05 <br />
<br />
现在配第二个。。用的原来的配置。copy过来的。。 &nbsp; 试了。改2.2 &nbsp; 2.0都不行。。不知道为什么。。 &nbsp; <br />
<br />
谁能给解释下。。。</span></div>
<p>&nbsp;</p>
<p>解决办法：</p>
<p>首先你确定你是否引入了NHibernate的程序集及使用的NHibernate的版本<br />
如果是1.0x或之前的请使用2.0<br />
如是是1.2.0GA或之后的使用2.2</p>
<p>&nbsp;</p>]]></description>
	<pubDate>Sun, 11 Nov 2007 22:54:01 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=26</guid>

</item>
<item>
	<title>NHibernate入门系列: 使用Criteria载入对象</title>
	<link>http://www.springframework.cn/blog/?post=25</link>
	<description><![CDATA[<p><span class="tpc_content">NHibernate会话提供一种使用表达式(就像SQL语句的where表达式)来载入数据的方法, 以取得满足条件的对象集合。<br />
<br />
通过CreateCriteria方法, 可以取得一个ICriteria接口, 这个接口用于操作表达式和排序字段. 由CriteriaImpl类实现，此类加有Internal修饰，因此不能在程序集外显示创建, CreateCriteria方法需要一个要加载对象类型的参数.<br />
<br />
这里列出ICriteria接口中的一些常用方法：<br />
<br />
Add：加入条件表达式(Expression对象)，此方法可多次调用以组合多个条件；<br />
AddOrder：加入排序的字段(Order对象)；<br />
List：执行查询, 返回满足条件的对象集合。<br />
SetMaxResults：设置返回的最大结果数，可用于分页；<br />
SetFirstResult：设置首个对象返回的位置，可用于分页；<br />
SetTimeout：设置操作的超时值，此值将传递给IDbCommand对象；<br />
<br />
<b>Expression(表达式)</b><br />
<br />
Expression类是所有表达式类的祖先. 这是一个抽象(abstract)类, 同时也是一个类工厂(Factory Method模式), 用于创建派生的表达式对象, 用意是很明显的, 隐藏了派生类的细节,使我们可通过一致的方法来创建表达式对象.<br />
<br />
下面列出一些Expression中常用的方法:<br />
<br />
Eq：得到一个相等判断的表达式, 等同于 propertyName = value;<br />
Gt：得到一个大于判断的表达式, 等同于 propertyName &gt; value; <br />
Like：得到一个相似判断的表达式, 等同于 propertyName like value; <br />
And：得到两个表达式And操作后的表达式, 等同于 expression1 and expression2; <br />
Or：重到两个表达式Or操作后的表达式, 等同于 expression1 or expression2;<br />
<br />
更多的Expression请参考相关文档或源代码。<br />
<br />
<b>Order(排序)</b><br />
<br />
Order类用于向ICriteria接口提供排序信息. 这个类提供了两个静态方法, 分别是Asc和Desc, 顾名思义就是创建升序和降序的Order对象.<br />
例如要取得一个按更新日期(Updated)降序的Order对象, 使用Order.Desc(&quot;Updated&quot;)就可以了.<br />
<br />
<b>示例</b><br />
<br />
<b>下面以几个例子来说明使用Criteria载入对象的用法：<br />
<br />
1. 取得用户名(Username)为billy的用户对象:</b><br />
<br />
Expression ex = Expression.Eq( &quot;Username&quot;, &quot;billy&quot; ); // ( Username = 'billy' )<br />
IList users = session.CreateCriteria(typeof(User)).Add( ex ).List();<br />
<br />
<b>2。取得用户名(Username)为billy, 密码(Password)为123456的用户对象</b><br />
<br />
Expression ex = Expression.And( <br />
Expression.Eq(&quot;Username&quot;, &quot;billy&quot;),<br />
Expression.Eq(&quot;Password&quot;, &quot;123456&quot;)<br />
); // ( Username='billy' and Password='123456' ) <br />
IList users = session.CreateCriteria(type(User)).Add( ex ).List();<br />
<br />
<b>3. 取得数据中第20-40的用户对象。</b><br />
<br />
ICriteria c = session.CreateCriteria(typeof(User));<br />
IList users = c.SetFirstResult(20).SetMaxResults(20).List(); <br />
<br />
对于SQLSERVER，数据定位采用的是IDataReader前滚至firstResult处，然后取maxResults条记录.<br />
<br />
<b>4. 取得按注册日期(Regdate)降序排序后的用户对象.</b><br />
<br />
ICriteria c = session.CreateCriteria(typeof(User));<br />
IList users = c.AddOrder( Order.Desc(&quot;Regdate&quot;) ).List(); <br />
<br />
使用Criteria加载数据的不足：<br />
<br />
1. 当使用SetFirstResult和SetMaxResults限制返回的对象数时，无法得知对象的总数；<br />
2. 当前版本不支持关联查询(hibernate好像可以)；</span></p>]]></description>
	<pubDate>Mon, 24 Sep 2007 23:28:14 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=25</guid>

</item>
<item>
	<title>Castle IOC容器与Spring.NET配置之比较</title>
	<link>http://www.springframework.cn/blog/?post=24</link>
	<description><![CDATA[<p>&nbsp; 我本人对于Spring.NET并不了解，本文只是通过一个简单的例子来比较一下两者配置之间的区别。在Castle IOC容器中，提出了自动装配（Auto-Wiring）的概念，即由容器自动管理组件之间的依赖关系，我们无需自己编写XML配置文件来配置组件之间的依赖关系。在Spring.NET中也是支持自动装配的，但是并不推荐使用，它贯穿着一种思想就是一切皆为XML配置，这是两者之间最大的一个区别。</p>
<p>&nbsp; 关于自动装配，来自于Spring.NET的支持者认为让容器自动管理，会让我们无法控制组件的依赖关系，如果该为XML配置，可以让我们知道自己在做什么，我们指定了哪些依赖关系，方便进行控制和管理；而来自于Castle IOC的支持者认为如果不让容器自动管理，手工配置会变得非常之复杂，配置文件也会变得非常繁冗，如果系统中的组件非常之多的时候，管理工作会变得很困难。</p>
<p>&nbsp; 我们来看一个简单的例子，有这样一个组件MyMainComponent，它依赖于MyComponent1、MyComponent2，并且它在构造函数中还需要接收一个整型的参数。<br />
<span style="background-color: #c0c0c0">public class MyMainComponent<br />
{<br />
MyComponent1 _com1;<br />
MyComponent2 _com2;<br />
int _i;<br />
public MyMainComponent(MyComponent1 com1,MyComponent2 com2,int i)<br />
{<br />
this._com1 = com1;<br />
this._com2 = com2;<br />
this._i = i;<br />
}<br />
}<br />
public class MyComponent1<br />
{<br />
public MyComponent1()<br />
{<br />
//<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
public class MyComponent2<br />
{<br />
public MyComponent2()<br />
{<br />
//<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
</span>&nbsp; 如果用采用Spring.NET，它采用XML进行组件之间的连接，配置文件如下，需要在配置文件中指定每一个对象及其它们之间的依赖，同时在配置文件中区分是构造函数还是其他方法：<br />
<span style="background-color: #c0c0c0">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />
&lt;configuration&gt;<br />
&lt;object id=&quot;myManComponent&quot; class=&quot;CastleDemo.MyMainComponent, CastleDemo&quot;&gt;<br />
&lt;constructor-arg&gt;<br />
&lt;ref object=&quot;mycomponent1&quot; /&gt;<br />
&lt;/constructor-arg&gt;<br />
&lt;constructor-arg&gt;<br />
&lt;ref object=&quot;mycomponent2&quot; /&gt;<br />
&lt;/constructor-arg&gt;<br />
&lt;constructor-arg&gt;<br />
&lt;value&gt;1&lt;/value&gt;<br />
&lt;/constructor-arg&gt;<br />
&lt;/object&gt;<br />
&lt;object id=&quot;mycomponent1&quot; class=&quot;CastleDemo.MyComponent1, CastleDemo&quot; /&gt;<br />
&lt;object id=&quot;mycomponent2&quot; class=&quot;CastleDemo.MyComponent2, CastleDemo&quot; /&gt;<br />
&lt;/configuration&gt;<br />
</span>Castle IOC中同样需要配置文件，但相比之下，就简单了很多：<br />
<span style="background-color: #c0c0c0">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;<br />
&lt;configuration&gt;<br />
&lt;components&gt;<br />
&lt;component id=&quot;myMainComponent&quot;&gt;<br />
&lt;parameters&gt;<br />
&lt;i&gt;1&lt;/i&gt;<br />
&lt;/parameters&gt;<br />
&lt;/component&gt;<br />
&lt;/components&gt;<br />
&lt;/configuration&gt;<br />
</span>&nbsp; 在Castle IOC中的配置并不需要指定组件之间的关联，它会自动通过Windsor来处理；我们只是配置了一个参数i，这个i是MyMainComponent中的构造函数中不存在依赖关系的那个参数。<br />
<span style="background-color: #c0c0c0">public class App<br />
{<br />
public static void Main()<br />
{<br />
IWindsorContainer container = new WindsorContainer(new XmlInterpreter(&quot;../../BasicUsage.xml&quot;) );<br />
container.AddComponent( &quot;myMainComponent&quot;,<br />
typeof(MyMainComponent));<br />
container.AddComponent( &quot;myComponent1&quot;,<br />
typeof(MyComponent1));<br />
container.AddComponent( &quot;myComponent2&quot;,<br />
typeof(MyComponent2));<br />
}<br />
}<br />
</span>&nbsp; 这样添加组件后， <br />
&nbsp; WindsorContainer会自动调用MicroKernel中的ConstructorDependenciesModelInspector来处理组件的构造函数依赖。</p>
<p>&nbsp; 通过上面的这个简单例子比较可以看出，如果我们想要增加一个组件之间的依赖关系或者增加一个组件使用Castle要比使用Spring.NET容易很多，Spring.NET复杂的配置文件会给我们开发带来很来不可预料的错误；Castle根据对象的依赖关系，采用自动装配，不需要配置组件的依赖，另外为了符合构造注入和属性注入，Castle的配置文件并没有像Spring.Net那样区分构造函数还是其他的方法，同时直接使用Parameters，而不是使用构造函数参数之类的区分。</p>]]></description>
	<pubDate>Sat, 01 Sep 2007 16:37:46 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=24</guid>

</item>
<item>
	<title>Hibernate性能调优</title>
	<link>http://www.springframework.cn/blog/?post=23</link>
	<description><![CDATA[<p>一。&nbsp; inverse = ?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inverse=false(default)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用于单向one-to-many关联<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;parent.getChildren().add(child) // insert child<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;parent.getChildren().delete(child) // delete child<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inverse=true<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用于双向one-to-many关联<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; child.setParent(parent); session.save(child) // insert child<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session.delete(child)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在分层结构的体系中<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parentDao, childDao对于CRUD的封装导致往往直接通过session接口持久化对象，而很少通过关联对象可达性&nbsp;</p>
<p>二。 one-to-many关系<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单向关系还是双向关系？<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.getChildren().add(child)对集合的触及操作会导致lazy的集合初始化，在没有对集合配置二级缓存的情况下，应避免此类操作<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select * from child where parent_id = xxx;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 性能口诀：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp; 一般情况下避免使用单向关联，尽量使用双向关联<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.&nbsp; 使用双向关联，inverse=&ldquo;true&rdquo;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.&nbsp; 在分层结构中通过DAO接口用session直接持久化对象，避免通过关联关系进行可达性持久化</p>
<p>&nbsp;</p>
<p>三。many-to-one关系<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单向many-to-one表达了外键存储方<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 灵活运用many-to-one可以避免一些不必要的性能问题<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; many-to-one表达的含义是：0..n : 1，many可以是0，可以是1，也可以是n，也就是说many-to-one可以表达一对多，一对一，多对一关系<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因此可以配置双向many-to-one关系，例如：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp; 一桌四人打麻将，麻将席位和打麻将的人是什么关系？是双向many-to-one的关系</p>
<p>四。one-to-one<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;通过主键进行关联<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 相当于把大表拆分为多个小表<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; 例如把大字段单独拆分出来，以提高数据库操作的性能<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hibernate的one-to-one似乎无法lazy，必须通过bytecode enhancement</p>
<p>五。集合List/Bag/Set&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;one-to-many<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp;&nbsp; &nbsp;List需要维护index column，不能被用于双向关联，必须inverse=&ldquo;false&rdquo;，被谨慎的使用在某些稀有的场合</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Bag/Set语义上没有区别<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;我个人比较喜欢使用Bag<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; many-to-many<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bag和Set语义有区别<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2。&nbsp;&nbsp; 建议使用Set</p>
<p>六。集合的过滤<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1.&nbsp; children = session.createFilter(parent.getChildren(), &ldquo;where this.age &gt; 5 and&nbsp;&nbsp; this.age &lt; 10&rdquo;).list()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;针对一对多关联当中的集合元素非常庞大的情况，特别适合于庞大集合的分页：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session.createFilter(parent.getChildren(),&ldquo;&rdquo;).setFirstResult(0).setMaxResults(10).list();</p>
<p>七。继承关系当中的隐式多态<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HQL: from Object<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp; 把所有数据库表全部查询出来<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;2.&nbsp;&nbsp;&nbsp;&nbsp; polymorphism=&ldquo;implicit&rdquo;(default)将当前对象，和对象所有继承子类全部一次性取出<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polymorphism=&ldquo;explicit&rdquo;，只取出当前查询对象</p>
<p>八。Hibernate二级缓存<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 著名的n+1问题：from Child，然后在页面上面显示每个子类的父类信息，就会导致n条对parent表的查询：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select * from parent where id = ?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .......................<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select * from parent where id = ?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 解决方案<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eager fetch<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 二级缓存</p>
<p>九。inverse和二级缓存的关系<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当使用集合缓存的情况下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp; &nbsp;inverse=&ldquo;false&rdquo;，通过parent.getChildren()来操作，Hibernate维护集合缓存<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp; inverse=&ldquo;true&rdquo;，直接对child进行操作，未能维护集合缓存！导致缓存脏数据<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp; 双向关联，inverse=&ldquo;true&rdquo;的情况下应避免使用集合缓存</p>
<p>十。Hibernate二级缓存是提升web应用性能的法宝<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OLTP类型的web应用，由于应用服务器端可以进行群集水平扩展，最终的系统瓶颈总是逃不开数据库访问；</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 哪个框架能够最大限度减少数据库访问，降低数据库访问压力，&nbsp;哪个框架提供的性能就更高；针对数据库的缓存策略：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 对象缓存：细颗粒度，针对表的记录级别，透明化访问，在不改变程序代码的情况下可以极大提升web应用的性能。对象缓存是ORM的制胜法宝。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 对象缓存的优劣取决于框架实现的水平，Hibernate是目前已知对象缓存最强大的开源ORM<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 查询缓存：粗颗粒度，针对查询结果集，应用于数据实时化要求不高的场合</p>
<p>十一。应用场合决定了系统架构<br />
一、是否需要ORM<br />
Hibernate or iBATIS？<br />
二、采用ORM决定了数据库设计<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hibernate：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 倾向于细颗粒度的设计，面向对象，将大表拆分为多个关联关系的小表，消除冗余column，通过二级缓存提升性能（DBA比较忌讳关联关系的出现，但是ORM的缓存将突破关联关系的性能瓶颈）；Hibernate的性能瓶颈不在于关联关系，而在于大表的操作<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iBATIS：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;倾向于粗颗粒度设计，面向关系，尽量把表合并，通过表column冗余，消除关联关系。无有效缓存手段。iBATIS的性能瓶颈不在于大表操作，而在于关联关系。</p>
<h4><span class="Code"><font color="#000000">总结：</font></span></h4>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 性能口诀<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1、使用双向一对多关联，不使用单向一对多<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、灵活使用单向多对一关联<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3、不用一对一，用多对一取代<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4、配置对象缓存，不使用集合缓存<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5、一对多集合使用Bag，多对多集合使用Set<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6、继承类使用显式多态<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7、表字段要少，表关联不要怕多，有二级缓存撑腰</p>]]></description>
	<pubDate>Sat, 07 Jul 2007 11:07:15 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=23</guid>

</item>
<item>
	<title>运行示例问题：“未将对象引用设置到对象的实例”</title>
	<link>http://www.springframework.cn/blog/?post=22</link>
	<description><![CDATA[<p>环境：Windows 2003 server, Sql Server 2005 Express<br />
按照示例安装步骤，附加了数据库，修改了数据库连接字符串，新建了一个网站。<br />
访问网站出现 &ldquo;未将对象引用设置到对象的实例&rdquo;错误。<br />
<br />
主要原因应该是：<br />
Error creating object with name 'RoleModuleManager' defined in 'assembly [FastSpring.Net.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null], resource [FastSpring.Core.spring.net_bean_business.xml]' : Initialization of object failed : 未将对象引用设置到对象的实例。]<br />
<br />
但查看了一下源码和配置又没有发现什么错误。<br />
到底是什么原因引起的呢。 <br />
我之前在XP（数据库也是2005）上是安装成功的。<br />
<br />
<br />
具体的错误信息如下：<br />
<br />
<br />
&ldquo;/FastSpring.Net.AppWeb&rdquo;应用程序中的服务器错误。<br />
--------------------------------------------------------------------------------<br />
<br />
未将对象引用设置到对象的实例。 <br />
说明: 执行当前 Web 请求期间，出现未处理的异常。请检查堆栈跟踪信息，以了解有关该错误以及代码中导致错误的出处的详细信息。 <br />
<br />
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。<br />
<br />
源错误: <br />
<br />
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。&nbsp; <br />
<br />
堆栈跟踪: <br />
<br />
<br />
[NullReferenceException: 未将对象引用设置到对象的实例。]<br />
&nbsp; Spring.Data.NHibernate.HibernateAccessor.ConvertAdoAccessException(ADOException ex) +80<br />
&nbsp; Spring.Data.NHibernate.HibernateTemplate.Execute(IHibernateCallback action, Boolean exposeNativeSession) +415<br />
&nbsp; Spring.Data.NHibernate.HibernateTemplate.FindByNamedQuery(String queryName, Object[] values, IType[] types) +132<br />
&nbsp; Spring.Data.NHibernate.HibernateTemplate.FindByNamedQuery(String queryName) +34<br />
&nbsp; FastSpring.Base.BaseDAO.FindEntityListByNamedQuery(String QueryName) +33<br />
&nbsp; FastSpring.Core.BLL.RoleManager.GetAllRoles() +33<br />
&nbsp; FastSpring.Core.BLL.RoleModuleManager.Init() +29<br />
&nbsp; FastSpring.Core.BLL.RoleModuleManager.set_CacheRoleManager(ICacheRoleManager value) +35<br />
&nbsp; Spring.DynamicReflection.Property_CacheRoleManager_d2abe0d6d80940a190d30e1049d3f579.SetValue(Object target, Object value) +86<br />
&nbsp; Spring.Reflection.Dynamic.SafeProperty.SetValue(Object target, Object value) +558<br />
&nbsp; Spring.Expressions.PropertyValueAccessor.Set(Object context, Object value) +130<br />
&nbsp; Spring.Expressions.PropertyOrFieldNode.SetPropertyOrFieldValueInternal(Object context, Object newValue) +37<br />
&nbsp; Spring.Expressions.PropertyOrFieldNode.SetPropertyOrFieldValue(Object context, EvaluationContext evalContext, Object newValue) +563<br />
&nbsp; Spring.Expressions.PropertyOrFieldNode.Set(Object context, EvaluationContext evalContext, Object newValue) +223<br />
&nbsp; Spring.Expressions.BaseNode.SetValue(Object context, IDictionary variables, Object newValue) +68<br />
&nbsp; Spring.Expressions.BaseNode.Spring.Expressions.IExpression.SetValue(Object context, Object newValue) +34<br />
&nbsp; Spring.Objects.ObjectWrapper.SetPropertyValue(IExpression propertyExpression, Object val) +37<br />
&nbsp; Spring.Objects.ObjectWrapper.SetPropertyValue(PropertyValue pv) +59<br />
&nbsp; Spring.Objects.ObjectWrapper.SetPropertyValues(IPropertyValues propertyValues, Boolean ignoreUnknown) +675<br />
&nbsp; Spring.Objects.ObjectWrapper.SetPropertyValues(IPropertyValues pvs) +30<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ApplyPropertyValues(String name, RootObjectDefinition definition, IObjectWrapper wrapper, IPropertyValues properties) +344<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.PopulateObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +976<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +117<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching) +675<br />
<br />
[ObjectCreationException: Error creating object with name 'RoleModuleManager' defined in 'assembly [FastSpring.Net.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null], resource [FastSpring.Core.spring.net_bean_business.xml]' : Initialization of object failed : 未将对象引用设置到对象的实例。]<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching) +827<br />
&nbsp; Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObject(String name, RootObjectDefinition definition, Object[] arguments) +42<br />
&nbsp; Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +191<br />
&nbsp; Spring.Objects.Factory.Support.WebObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +123<br />
&nbsp; Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name, Type requiredType, Object[] arguments) +542<br />
&nbsp; Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name) +57<br />
&nbsp; Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() +538<br />
&nbsp; Spring.Context.Support.AbstractApplicationContext.Refresh() +691<br />
&nbsp; Spring.Context.Support.WebApplicationContext..ctor(String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) +77<br />
&nbsp; Spring.Context.Support.WebApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) +41<br />
<br />
[TargetInvocationException: 调用的目标发生了异常。]<br />
&nbsp; System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct&amp; signature, IntPtr declaringType) +0<br />
&nbsp; System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType) +13<br />
&nbsp; System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +366<br />
&nbsp; System.Reflection.ConstructorInfo.Invoke(Object[] parameters) +14<br />
&nbsp; Spring.Util.ObjectUtils.InstantiateType(ConstructorInfo constructor, Object[] arguments) +591<br />
<br />
[FatalReflectionException: Cannot instantiate Type [Spring.Context.Support.WebApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] : '调用的目标发生了异常。']<br />
&nbsp; Spring.Util.ObjectUtils.InstantiateType(ConstructorInfo constructor, Object[] arguments) +792<br />
&nbsp; Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) +192<br />
&nbsp; Spring.Context.Support.ContextInstantiator.InstantiateContext() +147<br />
&nbsp; Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +137<br />
&nbsp; Spring.Context.Support.WebContextHandler.InstantiateContext(IApplicationContext parent, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +321<br />
&nbsp; Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) +426<br />
<br />
[ConfigurationErrorsException: Error creating context '/fastspring.net.appweb': Error creating object with name 'RoleModuleManager' defined in 'assembly [FastSpring.Net.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null], resource [FastSpring.Core.spring.net_bean_business.xml]' : Initialization of object failed : 未将对象引用设置到对象的实例。]<br />
&nbsp; System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +178<br />
&nbsp; System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object&amp; result, Object&amp; resultRuntimeObject) +896<br />
&nbsp; System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object&amp; result, Object&amp; resultRuntimeObject) +1221<br />
&nbsp; System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) +56<br />
&nbsp; System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +8<br />
&nbsp; System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) +65<br />
&nbsp; System.Configuration.ConfigurationManager.GetSection(String sectionName) +107<br />
&nbsp; Spring.Util.ConfigurationUtils.GetSection(String sectionName) +24<br />
&nbsp; Spring.Context.Support.WebApplicationContext.GetContextInternal(String virtualPath) +865<br />
&nbsp; Spring.Context.Support.WebApplicationContext.GetRootContext() +112<br />
&nbsp; Spring.Context.Support.WebSupportModule.Init(HttpApplication app) +386<br />
&nbsp; System.Web.HttpApplication.InitModulesCommon() +66<br />
&nbsp; System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +814<br />
&nbsp; System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +243<br />
&nbsp; System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +106<br />
&nbsp; System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +340</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>问题已解决，系数据库连接字符串的问题<br />
在原有的字符串基础需增加一个参数Persist Security Info=True;<br />
完整字符串为：<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;add key=&quot;DbProvider.ConnectionString&quot; value=&quot;Data Source=CHANGHONG-JQM\SQLEXPRESS;Initial Catalog=FastSpring20;Persist Security Info=True;User ID=fastspring;Password=fastspring;Trusted_Connection=False&quot;/&gt;</strong></p>]]></description>
	<pubDate>Thu, 24 Jul 2008 10:58:20 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=22</guid>

</item>
<item>
	<title>NHibernate 最佳实践|C#.NET 代码下载中心</title>
	<link>http://www.springframework.cn/blog/?post=21</link>
	<description><![CDATA[<div id="read_tpc" class="tpc_content">发个网址，我感觉这篇文章非常好，分享给大家，谈到了主流的各种技术，而且附带例子，大家自己去看吧，英文的。 <br />
<a target="_blank" href="http://www.codeproject.com/aspnet/NHibernateBestPractices.asp">http://www.codeproject.com/aspnet/NHibernateBestPractices.asp</a> <br />
&nbsp;</div>]]></description>
	<pubDate>Fri, 16 Nov 2007 17:00:51 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=21</guid>

</item>
<item>
	<title>实战C#.NET--Spring.NET &amp; NHibernate的整合</title>
	<link>http://www.springframework.cn/blog/?post=16</link>
	<description><![CDATA[<p>我所使用的语言：Visual Studio .NET 2003 C#<br />
关键字：Spring.NET,NHibernate,C#.NET<br />
<br />
<a style="color: #3366ff" id="Editor_Results_rprSelectionList_ctl03_LinkTitle" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html">C#.NET编程----Spring.NET &amp; NHibernate整合(一)</a><span style="color: #3366ff"> --Spring.NET入门</span><br />
这是一个简单的Spring.NET的例子。<br />
如果你还没有玩过Spring.NET，你一定要看一下这篇文章。他会告诉你怎么在项目中使用Spring.NET的IOC。<br />
<br />
<a id="Editor_Results_rprSelectionList_ctl02_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579060.html"><span style="color: #3366ff">C#.NET编程----Spring.NET &amp; NHibernate整合(二)</span></a><span style="color: #3366ff"> --NHibernate入门</span><br />
这是一个简单的NHibernate的例子。<br />
如果你没有触过Hibernate或NHibernate，你可以看一下，他会告诉你怎么在项目中使用NHibernate.<br />
<br />
<a id="Editor_Results_rprSelectionList_ctl01_LinkTitle" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579087.html"><span style="color: #3366ff">C#.NET编程----Spring.NET &amp; NHibernate整合(三) </span></a><span style="color: #3366ff">--Spring.NET &amp; NHibernate整合</span><br />
这篇文章将上面两篇结合在一起，让Spring.NET的IOC来管理NHibernate。<br />
&nbsp;</p>]]></description>
	<pubDate>Fri, 01 Dec 2006 11:11:39 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=16</guid>

</item>
<item>
	<title>Spring .NET 1.2.0 已经提供下载</title>
	<link>http://www.springframework.cn/blog/?post=15</link>
	<description><![CDATA[<p>Dear Spring Community, <br />
<br />
We are&nbsp;pleased to announce&nbsp;that Spring .NET 1.2.0 is now available. &nbsp;<br />
<br />
<a href="http://www.springframework.net/download.html">Download</a> | <a href="http://www.springsource.com/">Support</a> |&nbsp;<a href="http://www.springframework.net/documentation.html#Reference_Manual_and_API">Documentation</a> |&nbsp;<a href="http://forum.springframework.net/">Community</a><br />
<br />
This release contains the following new major features:<br />
&nbsp;</p>
<ul>
    <li class="newslist"><a href="http://www.springframework.net/docs/1.2.0/reference/html/wcf.html">WCF Integration</a> - Configure WCF services using dependency injection.&nbsp;Apply AOP advice to WCF services.</li>
    <li class="newslist"><a href="http://www.springframework.net/docs/1.2.0/reference/html/msmq.html">MSMQ integration</a> -&nbsp;MSMQ helper classes to increase your productivity developing messaging applications. &nbsp;Provides integration with Spring's transaction management features.</li>
    <li class="newslist"><a href="http://www.springframework.net/docs/1.2.0/reference/html/messaging.html">Apache ActiveMQ integration</a> - Helper classes to increase your productivity developing messaging applications with ActiveMQ/NMS</li>
    <li class="newslist"><a href="http://www.springframework.net/docs/1.2.0/reference/html/scheduling.html">Quartz integration</a> -&nbsp;Configure Quartz jobs, schedulers, triggers using dependency injection. Convenience classes for implementing Quartz Jobs.</li>
    <li class="newslist"><a href="http://www.springframework.net/docs/1.2.0/reference/html/aop.html#aop-inheritancebasedaopconfigurer">AOP</a> - New&nbsp;inheritance based AOP proxy generation</li>
    <li class="newslist">NHibernate 2.0.1&nbsp;support.</li>
</ul>
<p>Other notable new features:<br />
&nbsp;</p>
<ul>
    <li>Color code and XML listings in reference documentation.</li>
    <li>Introduction of <a href="http://www.springframework.net/docs/1.2.0/reference/html/objects.html#d4e2365">stereotype attributes</a> - for example [Repository]&nbsp;</li>
    <li><a href="http://www.springframework.net/docs/1.2.0/reference/html/wcf.html#d4e7876">WCF Service exporter</a>.</li>
    <li><a href="http://www.springframework.net/docs/1.2.0/reference/html/web.html#web-resultmapping-custom">Extensible web navigation</a>.</li>
    <li>Performance improvements in WebForm dependency injection.</li>
    <li><a href="http://www.springframework.net/docs/1.2.0/reference/html/index-quickstarts.html">QuickStart applications</a>&nbsp; for WCF, Quartz, MQMQ, and Apache Active MQ&nbsp;integration.</li>
    <li>Automatic registration of&nbsp;custom XML namespaces</li>
</ul>
<p>This release includes&nbsp;approximately 100&nbsp; bug fixes and enhancements since the 1.1.2 release.&nbsp;<br />
<br />
Please&nbsp;refer to the <a href="http://www.springframework.net/docs/1.2.0/changelog.txt">changelog</a> for additional details.<br />
<br />
<br />
Enjoy!<br />
<br />
[2008-11-10]<br />
&nbsp;</p>]]></description>
	<pubDate>Mon, 10 Nov 2008 18:43:39 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=15</guid>

</item>
<item>
	<title>FastSpring.NET V2.05 final 发布[集成Spring.net &amp; NHibernate &amp; Ajax]</title>
	<link>http://www.springframework.cn/blog/?post=3</link>
	<description><![CDATA[<p><span style="font-size: 12pt"><span style="font-size: 12pt">FastSpring.NET 是一个集成了Spring.NET &amp; NHibernate &amp; Ajax 的WEB开发框架。<br />
是国内第一个支持Spring.NET、NHibernate 及Ajax的开源的Framework.<br />
<br />
最新版本为V2.05 final，支持最新版的Spring.NET 1.1&nbsp;final&nbsp;和 NHibernate 1.2.1 GA<br />
欢迎大家下载开发文档与项目源代码，格式为微软的chm格式。<br />
<br />
下载地址：<font face="Courier New"><a target="_blank" href="http://fastspring.googlecode.com/files/FastSpring.NetV2.05-final.zip"><font color="#7297ce">http://fastspring.googlecode.com/files/FastSpring.NetV2.05-final.zip</font></a><br />
</font></span></span></p>]]></description>
	<pubDate>Wed, 02 Jan 2008 11:16:32 +0800</pubDate>
	<author>㊣阿华</author>
	<guid>http://www.springframework.cn/blog/?post=3</guid>

</item></channel>
</rss>