NHibernate.LazyInitializationException

前端 未结 2 901
时光说笑
时光说笑 2021-02-09 03:24

We have been having this issue pop up sporadically, but now I can reproduce it every time. I am incrementing a view counter on my custom built forums, which causes an error:

相关标签:
2条回答
  • 2021-02-09 03:50

    A little further research into this issue as it has reproduced itself is that in a single call back to the server, if you do a save and get, you need to flush the session. I do my flush after the save and that seems to have corrected the problem.

    0 讨论(0)
  • 2021-02-09 03:51

    Check to see that there aren't any other objects loaded in that session. I've had a similar situation occur in which I would call Save on an object that didn't have any Lazy Loading and it really sent me for a loop. Why would I get this error on an object that isn't lazy loading?

    In my situation I was loading several other objects into the page and these object weren't mapped properly. When I called Save NHibernate would try to synchronize in the session and throw the error.

    Try removing all other NHibernate, leaving just this counter update. If the error doesn't occur with just the counter slowly add back in you other calls until the error returns. Then you can start addressing the real culprit.

    0 讨论(0)
提交回复
热议问题