Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 505707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:37:33+00:00 2026-05-13T06:37:33+00:00

I am using NHibernate 2.1. I am trying to use a filter in a

  • 0

I am using NHibernate 2.1. I am trying to use a filter in a property formula, but am getting the following error:

filter-def for filter named ‘SiteFilter’ was never used to filter classes nor collections.

Here is my mapping file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataAccess" namespace="DataAccess.Catalog">
  <class name="Model.Catalog.Category,Model" table="Catalog.Category">

    <id name="ID" column="ID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>

    <property name="Name" column="Name" type="string" length="50" not-null="true" />

    <property name="ProductCount" formula="(SELECT COUNT(*) from Catalog.Product WHERE Product.CategoryID = ID)" lazy="true" />
    <property name="SiteProductCount" formula="(SELECT COUNT(*) from Catalog.Product WHERE Product.CategoryID = :SiteFilter.SiteID)" lazy="true" />

    <many-to-one name="Image"
                 column="ImageID"
                 not-null="true"
                 class="Model.Catalog.Image,Model"
                 cascade="save-update" />

    <bag name="Products" table="Catalog.Product" generic="true" inverse="true">
      <key column="CategoryID" />
      <one-to-many class="Model.Catalog.Product,Model"/>
    </bag>

  </class>

  <filter-def name="SiteFilter">
    <filter-param name="SiteID" type="Int32" />
  </filter-def>
</hibernate-mapping>

What am I doing wrong? Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:37:34+00:00Added an answer on May 13, 2026 at 6:37 am

    Checking the NHiberante source it appears that filters are not intended to be used in formulas.

    The nhibernate 2.0 documentation does not mention that you can use filters like this.

    Filters are intended to be used for entities and in collection mappings, like this:

    <class name="MyClass" ...>
       ...
       <filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
    </class>
    
    <set ...>
     <filter name="myFilter" condition=":myFilterParam = MY_FILTERED_COLUMN"/>
    </set>**
    

    The exception “filter-def for filter named ‘SiteFilter’ was never used to filter classes nor collections.” is being thrown after all configuration files have been read and a filter definition is found that is not used, that it is being used in a formula like you use here is not recognized.

    Sorry to come with bad news 🙂 If you feel that this is an important feature, please add it as feature request in the nhibernate jira (nhjira.koah.net).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use 'adonet.batch_size' property in NHibernate. Now, I'm creating entities across multiple
I am trying to use Nhibernate with Oracle using Microsoft's System.Data.OracleClient Nhibernate Configuration (Is
I'm trying to achieve some kind of nested transaction behavior using NHibernate's transaction control
Trying to use nhibernate on sql-server compact edition for unit testing and having some
I am trying to set up proper domain architecture using Fluent NHibernate and Linq
Hi I'm trying to map a one-many parent-child relationship in NHibernate using XML mapping.
I'm new to using NHibernate/Fluent NHibernate and am trying to figure out how to
I am using NHibernate in a project, and I am trying to add it
I'm trying to replicate many of the practices we use with NHibernate in EF
I have a C# .Net Web Service. I am trying to use nHibernate to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.