Search code examples
nhibernatenhibernate-mappingdenormalization

Are Denormalized Updates Possible With NHibernate Without Using a Stored Procedure?


I'm pondering the use of NHibernate on a project that has a database with some degree of planned denormalization (planned by the DBAs). Reading from one set of tables and mapping one column to one property is not a problem. However when updating I'd have to map one property back to the original column in the original table plus update a few copies of that column in the denormalized tables. Is it possible to do this with NHibernate without using stored procedures?

EDIT: Although I tend to agree with NXC's answer, this question is about how to solve the problem with NHibernate as opposed to solving it in the database.


Solution

  • Yes, you can register an event listener inheriting from DefaultSaveOrUpdateEventListener, override OnSaveOrUpdate and update the other entities.

    Here are some blog posts about event listeners: