0

在我的应用程序中,我有一个User只有一个类的Settings类。一对一的关系我有一个简单的用户 NHibernate 映射:

/// NHibernate declarations etc
<id name="squid" type="guid">
  <generator class="assigned" />
</id>
/// Properties
<one-to-one class="Settings" name="Settings" outer-join="true" cascade="save-update" />
/// Close tags & end file

我的设置类是

/// NHibernate declarations
<id name="squid" type="guid">
  <generator class="assigned" />
</id>
/// Properties, close tags & end of file

如您所见,我的用户被分配了一个基于其 Active Directory 帐户的 guid(或在我的单元测试中,由 生成的新 Guid Guid.NewGuid()

NHibernate 是否可以神奇地将设置 GUID 分配为用户 GUID?

4

1 回答 1

1

据我了解,您的示例更好地定义Settings为 Value 对象,因为没有User. 这是 Nhibernate 使用中的常见做法。您可以在此处阅读有关此内容的更多信息。

于 2012-08-26T15:49:09.013 回答