ano*_*ous 7 nhibernate interceptor
我认为这是一个简单的问题,但我的谷歌搜索在这方面很弱.
关于生成的ID和级联,我遇到了以下链接中描述的问题:
https://www.hibernate.org/hib_docs/nhibernate/html/example-parentchild.html(向下)
我使用他们建议的拦截器方法修复它.一切似乎都在起作用,所以我很开心.
也就是说,我不知道返回值的重要性来自以下方法:
public override bool OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types)
{
if (entity is Persistent) ((Persistent)entity).OnLoad();
return false;
}
public override bool OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types)
{
if (entity is Persistent) ((Persistent)entity).OnSave();
return false;
}
Run Code Online (Sandbox Code Playgroud)
在这两种情况下都会返回false.
当我谷歌关于NHibernate拦截器时,我看到了很多关于如何编写一个的例子.有些反而返回true(http://www.lostechies.com/blogs/rhouston/archive/2008/03/27/creating-a-timestamp-interceptor-in-nhibernate.aspx).我不知道这里的区别是什么.我的代码正在运行,但拦截器对我来说似乎很有用,所以我希望能有更好的理解.
| 归档时间: |
|
| 查看次数: |
1905 次 |
| 最近记录: |