NHibernate [..User.Groups] exception collection was not handled by flush ()

All my NH objects are obtained from the BusinessEntity type, this has the most basic values โ€‹โ€‹of ID, Created, CreatedBy, Updated, Updated .By.

CreatedBy / updatedBy accepts user

I have an IPreUpdateEventListener and IPreInsertEventListener that fire to get the current DateTime for audit values. Also here I have my logic to launch the current user that I grabbed by running the query criteria for the Windows user principle. From what I understand from all the messages in the NH user group on this subject, I need a custom class to be impatiently loaded so that it works correctly in my EventListeners, this is how I load the user

public User GetByDomainPrinciple(string domainPrinciple) { var domainPrincipleCriteria = DetachedCriteria.For<User>() .Add(Restrictions.Eq("DomainPrinciple", domainPrinciple)) .SetFetchMode("Roles", FetchMode.Eager) .SetFetchMode("Groups", FetchMode.Eager) .SetFetchMode("Groups.Roles", FetchMode.Eager) .SetCacheable(true); return Repository.QuerySingle(domainPrincipleCriteria); } 

Repository.QuerySingle(domainPrincipleCriteria); just

 return detachedCriteria .GetExecutableCriteria(_conversation.Session).UniqueResult<T>(); 

Am I missing something or incorrectly responding to my criteria? I think absolute. In the worst case scenario, I could change CreatedBy as a Guid and not a User and just assign an FK that way, but it seems very dirty.

+6
c # exception nhibernate
source share
2 answers

I think this can help you. The error is related to PreUpdateEventListener. I had the same problem when I returned.

http://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-ipreinserteventlistener.aspx

+1
source share

An error has occurred in NHibernate, which can be fixed using the custom DefaultFlushEventListener. See the answer here: fooobar.com/questions/644904 / ...

+2
source share

All Articles