【发布时间】:2009-04-24 15:36:55
【问题描述】:
我有一个相当复杂的场景/设计需要整理,非常感谢一些建议或见解。
我正在尝试映射以下内容,但收效甚微。
<class name="CalEvent" table="tb_calEvents" lazy="false" >
<id name="id" column="id">
<generator class="hilo"/>
</id>
<property name="summary"/>
---snip----
<bag name="categories" table="tb_calEvent_category" lazy="false">
<key column="parentID"/>
<one-to-many class="Category"/>
</bag>
/////////////////
<class name="Category" table="tb_calEvent_category" lazy="false">
<id name="id" column="id" unsaved-value="0">
<generator class="hilo"/>
</id>
<property name="categoryID"/>
<property name="parentID"/>
<property name="categoryType"/>
分类表
[id] bigint NULL [parentID] bigint NULL [类别类型] nvarchar(255) NULL [类别 ID] 整数 NULL 约束 [tb_calEvent_category_fk] 外键 ([parentID])
上面的 tb_calEvent_category 表似乎已被设置为一种查找表。 在各自的表格中有 3 种不同的类别; categoryType 是对该类别所在的表的引用,而 categoryID 是对该表主键的引用。
我在检索 calEvents 时没有问题,但无法干净地添加或更新。
有没有人想过我可以如何进行映射?可能吗?还是我必须跳过几个环节才能成功地将 calEvents 添加和更新到数据库?
我认为这个表是这样设置的,以减少连接,或者可以添加其他类别。嗯..
谢谢
【问题讨论】:
标签: sql-server nhibernate