为什么NHibernate说我的过滤器没有配置?
我试图在NHibernate中使用全局过滤器,据我所知,我正在做所有教程都做的事情,但我得到了一个例外 My.hbm.xml文件包含以下内容:为什么NHibernate说我的过滤器没有配置?,nhibernate,nhibernate-configuration,Nhibernate,Nhibernate Configuration,我试图在NHibernate中使用全局过滤器,据我所知,我正在做所有教程都做的事情,但我得到了一个例外 My.hbm.xml文件包含以下内容: ... <class name="NHibernateSandbox.Foo, NHibernateSandbox" table="Foo"> ... <property column="Content" type="String" name="Content" not-null="true" length="100"
...
<class name="NHibernateSandbox.Foo, NHibernateSandbox" table="Foo">
...
<property column="Content" type="String" name="Content" not-null="true" length="100" />
<property column="Deleted" type="Boolean" name="Deleted" not-null="true" />
<filter name="Foo_Nondeleted" condition="Deleted = false" />
</class>
如果我将log4net配置为详细,那么我会看到
INFO NHibernate.Cfg.HbmBinder - Mapping class: NHibernateSandbox.Foo -> Foo
DEBUG NHibernate.Cfg.HbmBinder - Mapped property: Id -> RID, type: Int32
DEBUG NHibernate.Cfg.HbmBinder - Mapped property: Content -> Content, type: String
DEBUG NHibernate.Cfg.HbmBinder - Mapped property: Deleted -> Deleted, type: Boolean
DEBUG NHibernate.Cfg.HbmBinder - Applying filter [Foo_Nondeleted] as [Deleted = false]
在应用筛选器和正在配置并可用于会话的筛选器之间缺少什么步骤?向类中添加筛选器是不够的:您还必须定义它。这归结为添加
<filter-def name="Foo_Nondeleted"></filter-def>
仅向类中添加筛选器是不够的:还必须定义它。这归结为添加
<filter-def name="Foo_Nondeleted"></filter-def>
<filter-def name="Foo_Nondeleted"></filter-def>
<filter name="Foo_Nondeleted" condition="Deleted = 0" />