Friday, December 17, 2010

Nhibernate/ActiveRecord Lazy Loading Fails when Ignore is Set

Recently our [BelongsTo] relationships in ActiveRecord with the Lazy = FetchWhen.OnInvoke have stopped lazy loading. This caused some massive performance problems. Suddenly entities that were not supposed to be loading unless invoked were loading all of the time.  I've been struggling with this for a couple days and just now found the answer.

Here is the property definition in question:



Normally, when retrieving an instance of "SomeEntity" the HomePage property would not load until it was accessed by some code. Two days ago, using the Nhibernate Profiler, I noticed that HomePage was being loaded...all of the time.

I tried so many possible solutions and searched for a possible answer until I came across this article.

It turns out that when you set NotFoundBehaviour=NotFoundBehaviour.Ignore on a BelongsTo relationship it circumvents the lazy loading and loads the entity anyway. I also found a bug that has been posted for this as well. Although the link rarely works well.

3 comments:

ishhu said...

Brilliant statistics, i like this sort of blog statistics truly very high-quality and greater I'm able to without difficulty new competencies are broaden after analyzing that publish.last time I visit write my essay this website also awesome Honey then again has many useful nutrients, enzymes, and antioxidants; uncooked honey is first-class as standard honey processing

Barbara Lopez said...

Download this us download dsploit apk ogyoutube latest version apk magisk apk download for android

ahmed said...

نحرص دائمًا على تقديم خدمة النقل على أفضل مستوى وكل الإمكانات الحديثة ، ونحن حريصون على تقديم أفضل الأسعار
شركة نقل عفش
شركة نقل اثاث من الرياض الى جدة

شركة نقل عفش من الرياض الى جدة
شركة نقل عفش بالاحساء