NHibernate的懒性的行为?行为、NHibernate

2023-09-03 07:28:07 作者:離開妳才懂_丶

我一直在试图让NHibernate的进入开发的一个项目我的工作我的工作场所。

I've been trying to get NHibernate into development for a project I'm working on at my workplace.

既然我已经把一个高度重视的表现,我一直在运行在现有的项目表中的概念验证型的压力测试的数千条记录,它们都含有大量文本列。 但是,选择这些记录集合时,select语句需要相当长的时间来执行;显然由于上述列

Since I have to put a strong emphasis on performance, I've been running a proof-of-concept stress test on an existing project's table with thousands of records, all of which contain a large text column. However, when selecting a collection of these records, the select statement takes a relatively long time to execute; apparently due to the aforementioned column.

这想到的第一个解决方案是设置该属性为延迟:

The first solution that comes to mind is setting this property as lazy:

<属性名=内容懒惰=真正的/>

但是,似乎是在由NHibernate的生成的SQL没有差别。 我的问题是,如何延迟加载的属性表现在NHibernate的?是否有某种类型的限制,我可能会错过?我应该采取不同的方法完全?

But there seems to be no difference in the SQL generated by NHibernate. My question is, how do lazy properties behave in NHibernate? Is there some kind of type limitations I could be missing? Should I take a different approach altogether?

使用HQL的新类(列1,列2)办法工作,但懒惰的特性听起来像一个简单的解决方案。

Using HQL's new Class(column1, column2) approach works, but lazy properties sounds like a simpler solution.

这也许值得一提的,我使用NHibernate 2.1.2GA与城堡DynamicProxy。

It's perhaps worth mentioning I'm using NHibernate 2.1.2GA with the Castle DynamicProxy.

谢谢!

推荐答案

要与2.1要做懒性能*,试试这个:

To do lazy properties with 2.1.*, try this:

的http://ayende.com/Blog/archive/2007/08/26/Lazy-Property-Loading-In-NHibernate.aspx

延迟属性更容易,并全力支持在树干(3.X):

Lazy properties are much easier and fully supported in the trunk (3.X):

的http://ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-lazy-properties.aspx

另请参阅:

http://stackoverflow.com/questions/2572498/lazy-property-loading-in-nhibernate-and-spring

http://stackoverflow.com/questions/2141149/nhibernate-lazy-loaded-properties