These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Property formula filter error
PostPosted: Wed Dec 09, 2009 12:07 pm 
Newbie

Joined: Wed Dec 09, 2009 12:04 pm
Posts: 2
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:

Code:
<?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!


Top
 Profile  
 
 Post subject: Re: Property formula filter error
PostPosted: Thu Dec 10, 2009 9:30 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Hmm, looks fine and according to this this should work:

http://ayende.com/Blog/archive/2006/12/26/LocalizingNHibernateContextualParameters.aspx

Have you enabled the filter on the session ?

session.EnableFilter("SiteFilter").SetParameter("SiteID", ...);

Maybe that's not working with NHIb 2.0 and 2.1 anymore. But then I would call it a bug. Have you checked JIRA if there's already an open issue ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: Property formula filter error
PostPosted: Thu Dec 10, 2009 9:57 am 
Newbie

Joined: Wed Dec 09, 2009 12:04 pm
Posts: 2
wolli wrote:
Hmm, looks fine and according to this this should work:

http://ayende.com/Blog/archive/2006/12/26/LocalizingNHibernateContextualParameters.aspx

Have you enabled the filter on the session ?

session.EnableFilter("SiteFilter").SetParameter("SiteID", ...);

Maybe that's not working with NHIb 2.0 and 2.1 anymore. But then I would call it a bug. Have you checked JIRA if there's already an open issue ?


It's not even getting to that point in my code. It errors when it builds the session factory. I didn't see anything on JIRA that would apply - do you think this is something I should post?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.