Nhibernate 我可以拥有IUserType实例的集合吗?

Nhibernate 我可以拥有IUserType实例的集合吗?,nhibernate,hibernate,nhibernate-mapping,Nhibernate,Hibernate,Nhibernate Mapping,是否可以拥有通过IUserType映射的实体集合?例如: class Foo { public int Id { get; set; } public ISet<Special> Items { get; set; } } class Special { public Special(string columnValue) { _val = columnValue; } public override string

是否可以拥有通过IUserType映射的实体集合?例如:

class Foo
{
    public int Id { get; set; }
    public ISet<Special> Items { get; set; }
}

class Special
{
    public Special(string columnValue)
    {
        _val = columnValue;
    }

    public override string ToString()
    {
        return _val.TranformInInterestingWays();
    }

    private string _val;
}

class SpecialUserTypeForMapping : IUserType
{
    // assume that all the right stuff is here
    // for using the non-default constructor on the way in
    // and calling ToString() on the way out
}
class-Foo
{
公共int Id{get;set;}
公共ISet项{get;set;}
}
特别班
{
公共特殊(字符串列值)
{
_val=列值;
}
公共重写字符串ToString()
{
返回_val.transformininterestingways();
}
私有字符串_val;
}
类SpecialUserTypeForMapping:IUserType
{
//假设所有正确的东西都在这里
//用于在导入过程中使用非默认构造函数
//并在退出时调用ToString()
}

如果我正确阅读了文档,那么
元素都不支持用于将IUserType映射应用于
s的“type”属性。那么我该如何映射它呢?

最方便的解决方案似乎是使用
元素,如下所示:

<class name="Foo" table="foos">
     <id  name="Id" />
     <set name="Items" table="foo_special">
         <key column="fooId" />
         <element column="special_value" type="SpecialUserTypeForMapping" />
     </set>
</class>

从数据库中检索不同的Foo实例没有问题,但是不清楚是否可以针对特殊的_值列编写查询,这是我的场景中的一个要求。似乎表明它不是