NHibernate 组件映射:操作数类型冲突:bigint 与时间不兼容

NHibernate component mapping: Operand type clash: bigint is incompatible with time

我正在编写一个通过代码使用 NHibernate 映射的应用程序。当我将 TimeSpan 映射为实体的 属性 时,TimeSpan 被正确映射。

但是,如果我将 TimeSpan 放在组件映射(值对象)中,我会得到一个 en 异常“操作数类型冲突:bigint 与时间不兼容”- 即使我确保使用 TimeSpan 映射来映射 TimeSpan。

以下代码将正确保存时间跨度(例如“1753-01-01T08:00:00”)

public class MyEntity
{
    public virtual int Id { get; protected set; }
    public virtual ISet<AnotherEntity> OtherEntities { get; protected set; }
}

public class AnotherEntity
{
    public virtual int Id { get; protected set; }
    public virtual TimeSpan MyTimeSpan { get; protected set; }
}

public class MyEntityMap : ClassMapping<MyEntity>
{
    public MyEntityMap()
    {
        Table("MyEntityTable");
        Id(x => x.Id, map =>
        {
            map.Column("Id");
        });

        Set(x => x.OtherEntities, c =>
        {
            c.Table("OtherEntityTable");
            c.Inverse(true);
            c.Key(k => k.Column("MyEntityId"));
        }, r => r.OneToMany(m =>
        {
            m.NotFound(NotFoundMode.Exception);
            m.Class(typeof(AnotherEntity));
        }));
    }
}

public class AnotherEntityMap : ClassMapping<AnotherEntity>
{
    public AnotherEntityMap()
    {
        Table("AnotherEntityTable");

        Id(x => x.Id, map =>
        {
            map.Column("AnotherEntityId");
        });

        Property(x => x.MyTimeSpan, m => m.Type<TimeAsTimeSpanType>());
    }
}

但是,以下代码将尝试将 TimeSpan 保存为 int(例如 288000000000)并抛出异常。 (类似地,当它试图水化嵌套值对象时抛出异常。)

public class MyEntity
{
    public virtual int Id { get; protected set; }
    public virtual MyValueObject MyValueObject { get; protected set; }
}

public class MyValueObject
{
    public virtual ISet<NestedValueObject> NestedValueObjects { get; protected set; }
}

public class NestedValueObject
{
    public virtual TimeSpan MyTimeSpan { get; protected set; }
}

public class MyEntityMap : ClassMapping<MyEntity>
{
    public MyEntityMap()
    {
        Table("MyEntityTable");
        Id(x => x.Id, map =>
        {
            map.Column("Id");
        });

        Component(x => x.MyValueObject, c =>
        {
            c.Set(x => x.NestedValueObjects, map =>
            {
                map.Table("NestedValueObjects");
                map.Key(k => k.Column("MyEntityId"));
            }, r => r.Component(n =>
            {
                n.Property(x => x.MyTimeSpan, m => m.Type<TimeAsTimeSpanType>());
            }));
        });
    }
}

映射有什么不正确的地方吗?还是 NHibernate 代码映射存在错误?

我假设这是 NHibernate 代码映射的一个错误,并提出了一个错误 NH-4038