views:

6

answers:

0

I have a filter defined for a property in a mapping file like this;

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
  <class name="Climate.Domain.CompanyAchievement, Climate.Domain" discriminator-value="0" table="CompanyAchievement">
    <id name="Id" column="Id" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="Type" column="[Type]" />
    <property name="Comment" column="Comment" />

    <property name="CurrentUserVoteId" formula="(select v.Id from Vote v where v.AchievementId=Id and (v.IP=:CurrentUserVoteFilter.CurrentUserIP))" lazy="true"></property>
    <property name="CurrentUserVoteType" formula="(select v.Type from Vote v where v.AchievementId=Id and (v.IP=:CurrentUserVoteFilter.CurrentUserIP))" lazy="true"></property>

    <many-to-one name="Company" column="CompanyId" />
  </class>
  <filter-def name='CurrentUserVoteFilter'>
    <filter-param name='CurrentUserIP' type='System.String'/>
  </filter-def>
</hibernate-mapping>

But when I want to create a query which has a relation with this class I always need to enable the filter for the current session. Should I always enable that filter for my whole queries? Or what is the appropriate method for this kind of issue?

Edit:

By the way you may know but I would like to point that out session.DisableFilter("CurrentUserVoteFilter") is not working for this condition.