nhibernate拦截select查询

发布于 2024-09-01 09:44:10 字数 146 浏览 2 评论 0原文

我正在看 nhibernate 拦截器。它似乎能够拦截保存、更新和删除查询,但无论如何我可以拦截选择查询。

我遇到的问题是,在某些情况下,我会自动将一些额外的 sql 过滤器附加到正在执行的 sql 语句中。

有什么想法

谢谢 垫

I'm looking at the nhibernate interceptor. It seems to be able to intercept save, update and delete queries but is there anyway I can intercept a select query.

The problem I have is that I automatically want to append some additional sql filters to the executing sql statement in certain cases.

Any thoughts

Thanks
Mat

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

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

发布评论

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

评论(3

哥,最终变帅啦 2024-09-08 09:44:10

拦截器框架仅允许您拦截实体操作,例如保存、更新和删除。查询本身不会被拦截,只有实体操作(选择/查看不算)。

考虑对附加到 ICriteria 的一组查询类使用某种继承来满足您的目的。

The interceptor framework only allows you to intercept entity operations like save, update, and delete. Queries themselves aren't intercepted, only entity operations (and selecting/viewing doesn't count).

Consider using some sort of inheritance for a set of query classes that append to your ICriteria to suit your purposes.

你在我安 2024-09-08 09:44:10

我认为你可以使用自定义 NHibernate 持久器来实现这一点;但是,我很难找到有关如何编写示例的示例......

I think you can accomplish that with a custom NHibernate persister; however, I'm having trouble finding examples on how you'd write one...

止于盛夏 2024-09-08 09:44:10

您可以在 class 标记上使用 where 属性:

<class name="MyClass" where="deleted=0">
    ...
</class>

You can use the where attribute on the class tag:

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