为什么在 ISession.Delete 之后需要调用 ISession.Flush

发布于 2024-10-08 14:20:34 字数 46 浏览 0 评论 0原文

为什么 NHibernate 要求我在删除后刷新会话?更新或保存后不需要刷新。

Why does NHibernate require me to flush the session after I delete? It doesn't do need a flush after updating or saving.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2024-10-15 14:20:34

除了删除之外,更新或保存后确实需要刷新。您的 ISession 的 FlushMode 设置或其他因素(例如数据库生成的标识符)导致它自动刷新。 文档描述了导致会话被刷新的条件。

在我看来,最佳实践是将 FlushMode 设置为 Commit 并对所有数据库操作(包括读取)使用事务(这是二级缓存所需的)。

It does need to flush after updating or saving in addition to delete. Your ISession's FlushMode setting or another factor (e.g. database generated identifiers) is causing it to flush automatically. The documentation describes the conditions that cause the session to be flushed.

In my opinion the best practice is to set the FlushMode to Commit and use transactions for all database operations, including reads (this is needed for 2nd level caching).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文