In a domain model where PKs are not always of the same type, a fairly complex architecture of interfaces and classes is defined.
Said architecture provide for:
Hence, every domain object has to implement both:
To make things even more complicated, some entities has lazy fields on them and a IPostLoadEventListener is used.
Problem is: all this machinery functioned pretty well... up until the latest release of NHibernate.
In 5.1, for all entities with lazies, when trying to access the aforementioned Id property inside of the IPostLoadEventListener, a StackOverflowException is thrown.
Please note that all three elements above are needed for the bug to trigger.