I am using decorators to decorate my entities. For example, I have a 
security decorator that hides values of entity properties not visible to 
the calling user. The decorators are put in place by special repositories 
decorating my common repositories. All this works as expected. 

However, this approach leads to a problem when objects are persisted. For 
example, due to the mapping NHibernate expects an InventoryItem entity, but 
will receive a SecurityInventoryItem (the decorated entity). As a result an 
exception stating "Object does not match target type" is thrown. This is 
totally understandable, however mapping the common interface IInventoryItem 
is not an option either because the decorators would hide valuable 
information from NHibernate. 

Is there any hook in NHibernate that is called for each entity to be saved 
/ updated that allows me to unwrap the entity (i.e transform entities 
before they are persisted)? I successfuly implemented the unwrapping for 
the save case with an IPreInsertEventListener, however I cannot find a way 
to do it for the update case.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to