Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:12:49+00:00 2026-05-30T01:12:49+00:00

I made a class that implements ILoadEventListener , and implemented an OnLoad() method (of

  • 0

I made a class that implements ILoadEventListener, and implemented an OnLoad() method (of course — else it wouldn’t even compile). After creating the “new NHibernate.Cfg.Configuration()”, I add it as the documentation says:

configuration.EventListeners.LoadEventListeners = new ILoadEventListener[] {
    new MyListener(),
    new NHibernate.Event.Default.DefaultLoadEventListener()
};

However, it never seems to get called — I’ve added logging statements to my OnLoad() and set a breakpoint there in the debugger — even when using my app in a way that clearly gets objects from the database using this NHibernate session factory.

What am I missing?

EDIT: I poked around in the source code (the NHibernate event documentation is rather sparse), and found that the event that corresponds to IInterceptor is actually PreLoad, not Load, so I tried using that, and that one does fire. So I can use that for now, but I still don’t really know what preload/load/postload are intended to be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:12:50+00:00Added an answer on May 30, 2026 at 1:12 am

    The documentation on this is practically nonexistent, so maybe this will help a few people:

    None of the Load events (Load/PreLoad/PostLoad) will ever fire on an entity that is in the identity cache, even if you Get, Load, or query for it again.

    This sort of makes sense if you squint at it just the right way, but it makes for a great deal of frustration due to non-deterministic behaviour, since most of the time, you won’t know whether or not an entity is in the cache. Evidently, these events refer to the process of hydrating an entity as opposed to simply requesting it.

    I haven’t tested this theory, but I wouldn’t be surprised if cache hits from the L2 cache also don’t fire Load events, since those entities won’t be hydrated either.

    In practice, this means that if you want a particular listener to run on “every” entity, you need to account for the possibility that it was originally a transient instance which was introduced to the session by Save, Update, etc. In other words, if you implement IPostLoadEventListener, you probably also want to implement IPostInsertEventListener and IPostUpdateEventListener.

    This won’t actually change the behaviour – the listener will still only ever run the very first time an entity becomes associated with the session – but at least this guarantees that every entity you can retrieve from the session has been intercepted by that listener. In my case, I was trying to use PostLoad to inject something into the entity, so this was an acceptable workaround.

    If you really need the listener to fire every time an entity is retrieved, you either need to use a stateless session (no cache) or evict the entities before loading/querying again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that implements an interface, which is made available for plugins.
I made a image thread class that runs the update method in the instance
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I have a JavaScript class that I have made and put it into its
This is a C++ class that I have made with n number of pointers.
I made a form class in c# that has a devexpress grid, a label
I have a custom-made view that extends the View class. I would like 2
I've got a class (which extends MovieClip) that loads in an external SWF (made
I've made some unit tests (in test class). The tutorial I've read said that
I have a class that implements ISelectionListener. I want to determine when the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.