【问题标题】:PersistanceSpecification CheckList fails on Many-to-Many relationshipPersistanceSpecification CheckList 在多对多关系上失败
【发布时间】:2011-04-26 17:32:00
【问题描述】:

我遇到了一个问题,我的单元测试有时会通过,有时会失败。我的单元测试使用 PersistanceSpecification 类来测试我的两个实体之间的多对多关系。似乎我遇到了与此处描述的完全相同的问题:

http://fluentnhibernate.lighthouseapp.com/projects/33236/tickets/170-persistencespecification-checklist-fails-on-many-to-many-relationship

有没有其他人遇到过这个问题,如果有,您是否能够在不放弃 PersistanceSpecification 的情况下解决或解决它?

我认为这一切都是在我将我的集合公开为带有私有支持字段的 IEnumerable 时开始发生的,而不是让属性直接访问底层集合。

这是我的实体及其映射的示例:

public class UserHeaderMap : ClassMap<UserHeader>
{
    public UserHeaderMap()
    {
        Id(x => x.UserId);

        HasManyToMany(x => x.Groups)
            .Table("USER_GROUP_COMPOSITE")
            .ParentKeyColumn("USER_ID")
            .ChildKeyColumn("GROUP_ID")
            .Access.CamelCaseField()
            .Cascade.All()
            .Inverse()
            .FetchType.Join();
    }
}

public class GroupHeaderMap : ClassMap<GroupHeader>
{
    public GroupHeaderMap()
    {
        Id(x => x.GroupId);

        HasManyToMany(x => x.Users)
            .Table("USER_GROUP_COMPOSITE")
            .ParentKeyColumn("GROUP_ID")
            .ChildKeyColumn("USER_ID")
            .Access.CamelCaseField();
    }
}

//Unit test runs the following (some things are omitted for brevity)
new PersistenceSpecification<UserHeader>(session)
                    .CheckList(x => x.Groups, groups, (x, g) => x.AddGroup(g))
                    .VerifyTheMappings();

【问题讨论】:

    标签: nhibernate fluent-nhibernate


    【解决方案1】:

    这实际上是 PersistanceSpecification 类中的一个错误,并且在 Fluent NH 中被跟踪。

    该错误在此处被跟踪: https://github.com/jagregory/fluent-nhibernate/issues/59

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      相关资源
      最近更新 更多