夏普架构 + NHibernate恩弗斯
目前我们使用的是 Sharp Architecture 1.9.6。 我们需要审核我们的域类。 使用 NHibernate Envers 来完成这项任务似乎很舒服。 但我无法配置 Sharp Architecture 来使用这个库。 有一些错误,但我解决了几乎所有错误,除了一个。
错误如下:
例如,我有名为“Document”的 POCO 类和表“Documents” 在数据库中。 我还创建了表“Documents_AUD”并添加了属性[已审核] 到“文档”类。 因此,如果 Document 类的某个对象发生了更改,Envers 必须添加数据 到“Documents_AUD”表。 为此,Envers 创建(动态?)另一个类的 ovbject - “文档_AUD”。 这里出现错误:“NHibernate.MappingException No Persister for Document_AUD”。
我不知道在哪里添加 Document_AUD 的映射。
有人使用 Envers 和 Sharp Arch 吗?有人可以分享 Envers + 锐拱配置?
非常感谢!
Currently we are using Sharp Architecture 1.9.6.
And we need to audit our domain classes.
It seems comfortably to use NHibernate Envers for this task.
But I couldn't configure Sharp Architecture to use this library.
There were some errors but I solved almost all of these except one.
The error is in following:
For example, I have POCO class named "Document" and table "Documents"
in DB.
Also I've created table "Documents_AUD" and added attribute [Audited]
to class "Document".
So, if some object of class Document has changed, Envers must add data
to "Documents_AUD" table.
To do this Envers create (dynamically?) ovbject of another class -
"Document_AUD".
And here the error appears: "NHibernate.MappingException No Persister
for Document_AUD".
And I don't know where to add mapping for Document_AUD.
Does somebody use Envers with Sharp Arch ? Can somebody share Envers +
Sharp Arch configuration?
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是 NHibernate.Envers 配置应该在构建会话工厂之前进行,但在将 hbm 映射添加到配置之后进行。在SharpArch中,当调用NHibernateSession.Init(..)时,它会立即构建会话工厂,并将其添加到本地缓存中。
解决方案是扩展 NHibernate.Init 方法,以利用 FluentNHibernate FluentConfiguration API,该 API 有一个
在添加流畅映射后立即调用的方法。
The problem is that NHibernate.Envers configuration should take place before building session factory, but after adding hbm mappings to configuration. In SharpArch, when calling NHibernateSession.Init(..), it will build the session factory immediately, adding it to a local cache.
The solution would be to extend NHibernate.Init method, to make use of FluentNHibernate FluentConfiguration API, which has a method
that is called right after adding fluent mappings.
您可以自己创建配置,在其上配置 Envers 并将其传递给 NHibernateSession.AddConfiguration(),而不是调用 Init 方法。
you can create the configuration yourself, configure Envers on it and pass it to NHibernateSession.AddConfiguration() instead of calling the Init method.