Hi, 
I'm adding Multilanguage support to my application. 
User should see localized data based on language selected in UI.

I'm trying to implement this as one-to-one mapping with filter on culture 
selected.

It works good for Session.Get<>, but looks like filters are not working when 
I'm using Session.Query<>.
It fails with error NHibernate.HibernateException : More than one row with 
the given identifier was found: 7, for class: Entities.Employee

Can you suggest how to make filter work with one-to-one mapping?
Thanks

Please see details below and unit-tests attached.

*Tables:*
People
======
Id int PK
Name 

Employees
=========
Id int PK
Person int FK(People.Id)
Role
CultureCode


*Mapping*
 <class name="Employee" table="Employees">
    <id name="Id">
      <generator class="native" />
    </id>

    <property name="Role" />
    <property name="CultureCode">
      <column name="CultureCode" sql-type="char(2)" />
    </property>

    <many-to-one name="Person" unique="true" column="Person"  />
    <filter name="CultureFilter"  condition=":cultureCode = CultureCode"/>
  </class>

  <class name="Person" table="People">
    <id name="Id">
      <generator class="native" />
    </id>
    <property name="Name" />
    <one-to-one name="Employee" class="Employee" constrained="true" 
property-ref="Person" fetch="join"/>
  </class>

  <filter-def name="CultureFilter">
    <filter-param name="cultureCode" type="System.String" />
  </filter-def>


*Classes *
    public class Person
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }

        public virtual Employee Employee { get; set; }
    }

    public class Employee
    {
        public virtual int Id { get; set; }
        public virtual string Role { get; set; }
        public virtual string CultureCode { get; set; }

        public virtual Person Person { get; set; }
    }



-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Attachment: tests.cs
Description: Binary data

Reply via email to