NHibernate 拦截器 - 它是什么
什么是 NHibernate 拦截器,它在应用程序中的用途是什么?
另外,在这篇文章中,我了解到使用 NHibernate 可以制作桌面应用程序在启动时速度较慢,因此为了避免这种情况,我需要将配置保存在文件中,然后从保存的文件中加载它。我怎样才能做到这一点?我在该教程中没有找到任何示例。
What is NHibernate Interceptor, and what purpose does it serve in an application?
Also, in this article, I learned that using NHibernate makes a desktop application slower at startup, so to avoid this, I need to save the configuration in a file, and later load it from the saved file. How can I do that? I didn't find any examples in that tutorial.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
拦截器允许您在数据库中检索/删除/更新/插入实体时执行附加功能...
拦截器文章
Hibernate 文档
其他有用信息
关于让您的应用变慢:
我建议您只在启动时间真正成为问题时才考虑优化启动时间。
当你构建一个会话工厂时,NHibernate 将解析所有映射,这是一个有点昂贵的操作。但是,只要实体数量有限,对性能的影响就不会那么大。
由于启动时间很慢,我从来没有必要优化 NHibernate 的初始化。
我建议您首先关注应用程序的核心 - 您试图解决的问题 - 然后看看如何提高启动性能。
(如果你必须这样做的话)。
An interceptor allows you to execute additional functionality when an entity is retrieved / deleted / updated / inserted in the DB ...
Interceptors article
Hibernate doc
other useful info
About making your app slower:
I'd suggest that you only have a look at optimizing start-up time, when it really becomes a problem.
When you build a session-factory, NHibernate will parse all the mappings, and that is an operation that is a bit expensive. But, as long as you have a limited number of entities, the performance hit isn't that big.
I have never ever had to optimize the initialization of NHibernate, because of slow startup times.
I'd suggest that you first concentrate on the core of your application -the problem you're trying to solve- and afterwards have a look on how you could improve startup performance.
(If you'll ever have to do it).
拦截器,就像名字本身所说的那样,允许您拦截 NHibernate 操作(保存/更新/删除/加载/刷新/等)。
实现此目的的更新、更灵活的 API 是事件系统< /a>.
关于序列化配置,代码就在那里,它是在应用程序启动时调用的类
Effectus.Infrastruct.BootStrapper
。Interceptors, like the name itself says, allows you to intercept NHibernate operations (save/update/delete/load/flush/etc).
A newer, more flexible API to achieve this is the event system.
About serializing the configuration, the code is there, it's the class
Effectus.Infrastructure.BootStrapper
which is called at application startup.我写的拦截器解剖系列可以在这里找到
http://blog.scooletz.com/ 2011/02/03/nhibernate-interceptor-magic-tricks-pt-1/
希望有帮助
An interceptor's dissection series written by me can be found in here
http://blog.scooletz.com/2011/02/03/nhibernate-interceptor-magic-tricks-pt-1/
hope it helps