在我的应用程序中,我有一个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我的Settings类是
/// NHibernate declarations
<id name="squid" type="guid">
<generator class="assigned" />
</id>
/// Properties, close tags & end of file因此,正如您所看到的,我的用户被分配了一个基于其Active Directory帐户的guid (或者在我的单元测试中,是由Guid.NewGuid()生成的一个新Guid )
NHibernate有没有可能神奇地将设置GUID指定为用户GUID?
发布于 2012-08-26 23:49:09
据我所知,您的示例最好将Settings定义为值对象,因为如果没有User,它就没有意义。这是Nhibernate使用中的常见做法。您可以阅读有关此here的更多信息。
https://stackoverflow.com/questions/12111673
复制相似问题